Skip to content

Failed to run spring boot tests #1546

Closed

Description

@jdneo

nickzhums Martin Lippert (@martinlippert) I've installed the pre-release version of Spring Boot Tools. I can confirm that I had no issues with autocompletion at the time of the usage. However, the test span was rather short, ~10 minutes. But normally it was enough to just change a symbol once to encounter the bug. So, a green light from me.

However, after installing the said extension I also did launch the test suite run with the other extension that is called Test Runner for Java (vscjava.vscode-java-test). And the difference was, that the test suite that used to be green before Spring Boot Tools installation now became partially red. "SpringBootTest"-based tests went red, with the following error:
javax.management.InstanceAlreadyExistsException

I've removed the extension, and the suite went green again. I guess, this issue is well described here:
#1420

Thanks

Originally posted by Nikita Pavlovski (@nikitades) in redhat-developer/vscode-java#1765 (comment)

Activity

  1. jdneo commented on Mar 14, 2023

    @jdneo
    MemberAuthor

    Nikita Pavlovski (@nikitades) instead of uninstalling the extension. Have you tried to turn off boot-java.live-information.automatic-connection.on?

  2. nikitades commented on Mar 14, 2023

    @nikitades

    Sheng Chen (@jdneo) I can confirm that with
    "boot-java.live-information.automatic-connection.on": false
    Extension "Test runner for Java" starts working properly, and "already exists" error does not appear anymore.

    All good.

    Thanks! ❤️

  3. jdneo commented on Mar 15, 2023

    @jdneo
    MemberAuthor

    Nikita Pavlovski (@nikitades) Thanks for the update.


    Hi Alex Boyko (@BoykoAlex)

    I remember this issue is fixed with spring-projects/spring-tools@ec8a5a8. Looks like it appears again recently. Is there anything changed at the spring boot extension side?

  4. martinlippert commented on Mar 15, 2023

    @martinlippert

    Sheng Chen (@jdneo) Can you share the launch config of the tests that you are running?

  5. jdneo commented on Mar 15, 2023

    @jdneo
    MemberAuthor

    The launch config looks like below if I run the tests from the spring petclinic project.

    {
      "name": "Launch Java Tests - $(symbol-class) ValidatorTests",
      "type": "java",
      "request": "launch",
      "mainClass": "org.eclipse.jdt.internal.junit.runner.RemoteTestRunner",
      "projectName": "spring-petclinic",
      "cwd": "C:\\Users\\xxx\\Documents\\work\\sample-project\\spring-petclinic",
      "classPaths": [
        ...
      ],
      "modulePaths": [],
      "args": [
        "-version",
        "3",
        "-port",
        "57985",
        "-testLoaderClass",
        "org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader",
        "-loaderpluginname",
        "org.eclipse.jdt.junit5.runtime",
        "-testNameFile",
        "C:\\Users\\xxx\\AppData\\Local\\Temp\\xxx.txt",
        "--exclude-tag",
        "aaa"
      ],
      "vmArgs": [
        "-ea"
      ],
      "noDebug": true,
      "__progressId": "889e23e4-92ff-445b-bc0b-7a10892c5342",
      "console": "internalConsole"
    }
    
    

    Nikita Pavlovski (@nikitades) could you share a sample project for this issue?

  6. BoykoAlex commented on Mar 15, 2023

    @BoykoAlex

    Sheng Chen (@jdneo) It'd be great to fully reproduce this use case. Share the project with the testFileName file and contents... Or provide instructions how this launch.json has been generated as it seems like i have assemble missing pieces of the config manually (i.e. classpath test class names file etc).
    Sounds like you were able to reproduce the issue with spring-petclinic project... Please provide instructions on how to reproduce this issue starting from the "vanilla" petclinic project downloaded from spring io.

    There is nothing changed around launching and connecting to apps as far as I remember... I also see that canConnect(...) method checks if main class is not one of the test runner classes (i.e. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner) here. The config above has exactly the class name that is being watched for thus I'm puzzled why it is an issue...

    I have tried launching the tests from the tab (don't think there is launch.json generated for this) as well as just running all tests within a test class - all seems to run fine. My attempt to launch the config above ended with unable to connect via port... but I'll keep trying for now until i have better steps to reproduce the issue.

  7. jdneo commented on Mar 16, 2023

    @jdneo
    MemberAuthor

    Alex Boyko (@BoykoAlex) I'm not able to reproduce it via the spring-petclinic. It's just working perfectly.

    The launch config I shared just in case if there is any clue to troubleshoot the problem.

    Recently there are several reports about the boot-java.live-information.automatic-connection.on will impact the test execution. Besides this issue, another one can be found here: #1530. But unfortunately, none of the users shared a sample project 😢.

  8. BoykoAlex commented on Mar 16, 2023

    @BoykoAlex

    I see, thanks for the clarification... Seems like I'd need a sample project to reproduce this as well...

  9. github-actions commented on Apr 4, 2023

    @github-actions

    This issue has been closed automatically because it needs more information and has not had recent activity. Please reach out if you have or find the answers we need so that we can investigate further.

  10. bradlord commented on May 15, 2023

    @bradlord

    I'm experiencing the same issue, where tests are failing with a javax.management.InstanceAlreadyExistsException when the tests are run through Test Explorer with STS's live information enabled. Here is a repository containing a minimal example:

    https://github.com/bradlord/spring-boot-sts-test-failure

    The tests in that repository succeed when boot-java.live-information.automatic-connection.on is set to false, but they fail when it is true. The key to reproducing the error seems to be defining multiple test classes with different parameters in the @SpringBootTest annotation:

    @SpringBootTest
    class DemoApplicationTests {/* ... */}
    
    @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
    class MoreDemoApplicationTests {/* ... */}
    

    Thank you.

  11. BoykoAlex commented on May 15, 2023

    @BoykoAlex

    Bradley Lord (@bradlord) I couldn't get the gradle project working in vscode, therefore, I have convrted your project into Maven project:
    sts-test-failure.zip

    Tests run fine... do you mind tweaking that specific Maven project into something that has test failures? It is important to include .vscode folder under your project as well as it might be that your creating a launch config that results in the test failures... I launched tests by opening the test source and clicking on the test run icon in the gutters.

  12. BoykoAlex commented on May 15, 2023

    @BoykoAlex

    Bradley Lord (@bradlord) actually, NVM, got one of the tests to fail if run from the explorer

  13. BoykoAlex commented on May 15, 2023

    @BoykoAlex

    Bradley Lord (@bradlord) fixed with spring-projects/spring-tools@a906005 Feel free to try the pre-release version of Spring Boot Tools a few days later. Thanks very much for reporting this and providing a test project!

  14. jdneo commented on May 16, 2023

    @jdneo
    MemberAuthor

    Thank you for the help Alex Boyko (@BoykoAlex)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions