简体   繁体   中英

Eclipse Gradle Project No JUnit Tests found

I'm using Kubuntu 18.04

Whenever I make a new JUnit Test Case inside a Gradle Project in Eclipse, and this test file goes to src/test/java, when I click: Test.java -> Run As -> JUnit Test

I get the message: "No JUnit Tests Found"

The project and the tests work fine on Windows 10. Everything copy-pasted. They just don't work in my Kubuntu 18.04.

Capture of Gradle Project

Message that not JUnit tests are found

Did you add annotation @Test for method? Sample like that:

public class SampleTest {

    @Test
    public void test(){
        System.out.println("Test run");
    }
}

Is it not a problem with eclipse cache? I remember similar problem for maven (with turned off autobuilding), for such situation with maven, you would have to rebuild project, maven refresh - alt+f5 , and I don't know whether similar action is possible for gradle.

I finally found the issue:

Turns out it was the Java library that didn't detect the JUnit 4 tests. By default, my eclipse uses the JavaSE-11, but the one that worked was the JavaSE-1.8 in the JRE System Library.

I don't know why JavaSE-11 causes this error, though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM