Skip to content

Cannot run from src/test anymore #413

Closed

Description

(maven project)
Since today I noticed when I try to start debugging something from the src/test folder I get:

Error: Could not find or load main class com.github.whatever.Whatever

When I move the file to the src/main folder it works. Before this was not the case.

It broke from one day to the other, so I guess VSCode or one of the plugins broke.
I have no clue how to tackle this problem. Any help is welcome.

Environment
  • Operating System: OSX 10.12.6
  • JDK version: 1.8
  • Visual Studio Code version: 1.27.1
  • Java extension version: 0.30.0
  • Java Debugger extension version: 0.12.2

Activity

  1. andxu commented on Sep 10, 2018

    @andxu
    Contributor

    Yes, it is caused by the code fix for this issue #111, for a workaround, you can move it to non-test folder, I will detect whether you are staring main class from test source folders later.

  2. lashchev commented on Sep 10, 2018

    @lashchev

    Same thing here (same VSCode, Java Tools and Java Debugger versions, but under Windows) - cannot debug unit tests anymore. I cannot move all unit tests to other folder - build and other tools rely on standard maven project structure.

    1. Debug session starts, but after few (2-5) steps (F10) it hangs. Pressing Shift+F5 stops debug session.
    2. Cannot add some local variables and method parameters to the Watch list.
    3. Mouse over doesn't show values for many variables
    4. Conditional breakpoints never stop. If I set them - debug session starts and runs forever.

    Language Support for Java log panel shows "Exception processing async thread queue"

  3. andxu commented on Sep 10, 2018

    @andxu
    Contributor

    Unit test by click Debug Test code lens should not be influenced, please go to the https://github.com/Microsoft/vscode-java-test/issues to raise an issue if you can not run unit test, but if you want to run the main method at test classes, it should not work by now due to my change.

  4. andxu commented on Sep 12, 2018

    @andxu
    Contributor

    Sheng Chen (@jdneo) to take a look at test runner side.

  5. joshryanne commented on Sep 12, 2018

    @joshryanne

    glad to know there wasn't wrong with my dev pc :) tried everything(uninstalling vs code, using insider edition, uninstalling plugins etc. manual classpath) but coudn't fix it. eventually went to eclipse temporarily :). so i'm happy to know what was the cause. :)

  6. clankill3r commented on Sep 12, 2018

    @clankill3r
    Author

    No I hope it get's fixed fast :)

  7. joshryanne commented on Sep 12, 2018

    @joshryanne

    i rolled back mine to 0.11.0 till it is solved :)

  8. lashchev commented on Sep 14, 2018

    @lashchev

    Andy Xu(devdiv) (@andxu) It fails for me from both places - from Test runner and Code Lens. Actually, I rarely use Test Runner to start tests, because when I develop a method/test I run/debug tests that I am working on or fixing. I use Test Runner is for big/sweep runs.

  9. andxu commented on Sep 14, 2018

    @andxu
    Contributor

    lasalame I will work on this items after the release 0.13.0, can you help to give me a sample project which doesn't work for both places(attach the project folder here in this issue)?

  10. andxu commented on Sep 26, 2018

    @andxu
    Contributor
  11. andxu commented on Sep 27, 2018

    @andxu
    Contributor

    To test it:

    1. maven:
      a. git clone https://github.com/andxu/samples and git checkout andy_test
      b. open the simple-app folder, and open the samples\simple-app\src\test\java\hello\GreeterTest.java
      c. set breakpoint on line 18
      d. click the debug code lens before the main method
      e. verify the GreeterTest is launched with the correct class path.

    image

    0 21 57548 n:\jdk1.8.0_181\bin\java -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=localhost:52207,server=n,suspend=y -Dfile.encoding=UTF-8 -cp N:\andxu\samples\simple-app\target\classes;N:\andxu\samples\simple-app\target\test-classes;C:\Users\andxu\.m2\repository\org\apache\commons\commons-lang3\3.6\commons-lang3-3.6.jar;C:\Users\andxu\.m2\repository\joda-time\joda-time\2.9.2\joda-time-2.9.2.jar;C:\Users\andxu\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\andxu\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar hello.GreeterTest

    1. gradle:
      a. git clone https://github.com/andxu/samples and git checkout andy_test
      b. open the gradle-sample folder, and open the samples\gradle-sample\src\test\java\hello\GreeterTest.java
      c. set breakpoint on line 18
      d. click the debug code lens before the main method
      e. verify the GreeterTest is launched with the correct class path(same with maven scenario above).
  12. clankill3r commented on Oct 1, 2018

    @clankill3r
    Author

    Can other people get this to work?
    I get:
    Error: Could not find or load main class hello.GreeterTest.

    (Edit: I guess I have to wait for the 0.14.0 release)...

  13. clankill3r commented on Oct 1, 2018

    @clankill3r
    Author

    joshryanne I want to roll back as well, do you happen to know what the VSIX link is?

    It such a pain to find it. The link should be close to this:

    https://ms-vscode.gallery.vsassets.io/_apis/public/gallery/publisher/ms-vscode/extension/vscjava.vscode-java-debug/0.12.0/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage

    But we are dealing with microsoft here...

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions