Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode not finding unit tests

For some reason my VSCode is not finding my unit tests in my "Test Explorer". It is able to find the class but not any of the methods in the class. I think that I must have something misconfigured in my vscode setup but not sure what.

Below is my stub of a class that I am trying to run.

/**
 * Unit test for simple App.
 */
public class AppTest 
    extends TestCase
{
    /**
     * Create the test case
     *
     * @param testName name of the test case
     */
    public AppTest( String testName )
    {
        super( testName );
    }

    /**
     * @return the suite of tests being tested
     */
    public static Test suite()
    {
        return new TestSuite( AppTest.class );
    }

    /**
     * Rigourous Test :-)
     */
    public void testApp()
    {
        assertTrue( true );
    }
    }
like image 706
mornindew Avatar asked Feb 03 '26 06:02

mornindew


1 Answers

I just had the same problem. All my test classes were not annotated with "Run Test" and "Debug test". I fixed the problem in vs code the following way:

In my Java Projects overview within the vs code ( In the Explorer section with open editors etc.) click on the "more actions" button ( the three dots ).

enter image description here

Click : "Clean workspace"

Accept the prompt:

enter image description here

like image 119
FishingIsLife Avatar answered Feb 04 '26 19:02

FishingIsLife



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!