Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I run the spring source code test class, I get an error: No tests fount with test runner 'JUnit 5' #1675

Open
chang6666 opened this issue Mar 27, 2024 · 8 comments
Labels

Comments

@chang6666
Copy link

as title,When I run the spring source code test class, I get an error: No tests fount with test runner 'JUnit 5'
CleanShot 2024-03-27 at 09 41 53@2x
eg:spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java

@jdneo
Copy link
Member

jdneo commented Mar 27, 2024

Is your java file name the same as your test primary class name? e.g.

class AbstractPropertyAccessorTests {
...
}

@chang6666
Copy link
Author

@jdneo yes it is the same,I run the same code in idea without any exception,The source code address is at
https://github.com/spring-projects/spring-framework/blob/6.1.x/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java

@jdneo
Copy link
Member

jdneo commented Mar 27, 2024

wait, what's the version of the test runner extension you are using? We've deprecated the code lens shortcuts for years.

@chang6666
Copy link
Author

@jdneo
CleanShot 2024-03-27 at 17 05 52@2x

@jdneo
Copy link
Member

jdneo commented Mar 27, 2024

Where do those Run Test | Debug Test come from? I don't understand. We are using gutter icon now. Do you install other java extension?

@chang6666
Copy link
Author

@jdneo Now that I have removed other test plug-ins, I still get an error
CleanShot 2024-03-28 at 11 31 51@2x

@jdneo
Copy link
Member

jdneo commented Mar 28, 2024

Thank you. I need to make some investigation. Highly likely that we could not handle abstract test class.

To reproduce, simply use:

public abstract class AbstractTest {

    @Test
    void testName() {

    }
}

@jdneo jdneo added the bug label Mar 28, 2024
@jrg94
Copy link

jrg94 commented Sep 10, 2024

Is the extension able to handle test cases in an abstract class? We recently shifted from Eclipse to VSCode. The following example test file matches your example above:

public abstract class QueueTest {

    /**
     * Invokes the appropriate {@code Queue} constructor for the implementation
     * under test and returns the result.
     *
     * @return the new queue
     * @ensures constructorTest = <>
     */
    protected abstract Queue<String> constructorTest();

    /**
     * Invokes the appropriate {@code Queue} constructor for the reference
     * implementation and returns the result.
     *
     * @return the new queue
     * @ensures constructorRef = <>
     */
    protected abstract Queue<String> constructorRef();

    @Test
    public final void testNoArgumentConstructor() {
        /*
         * Set up variables and call method under test
         */
        Queue<String> q = this.constructorTest();
        Queue<String> qExpected = this.constructorRef();
        /*
         * Assert that values of variables match expectations
         */
        assertEquals(qExpected, q);
    } 
}

The tests correctly have run buttons next to the line numbers, but clicking them raises an error (i.e., no tests found with testrunner JUnit 4). The class that inherits these tests can be executed just fine. I've been trying to figure out a workaround because my students often click these run buttons and wonder what's wrong.

For the record, switching to JUnit 5 actually makes the issue worse. Test failures no longer show alongside the correct test case and instead all of them show up on the class declaration line.

I can open another issue if this is not the appropriate location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants