简体   繁体   中英

Eclipse - When I create a JUnit Suite, the list of test classes is empty. Why?

I have a package with 4 test classes. I want to make a JUnit Test Suite. So in Eclipse, I right click my package and do New > Other > JUnit Test Suite

The wizard has a warning that, "Warning: No test classes selected" and the list of Test Classes to include in suite: is empty.

I'm not sure why. I have several *Test.java classes with public methods annotated with @Test . I created these through the JUnit Test Case wizard...

I saw some code on other Stack Overflow answers that I could use to create a Test Suite, but why isn't it working in the IDE?

Should I even bother with a Test Suite? It seems like I can just right click the package and Run As > JUnit Test .

Yeah, don't bother with Suites.

You can select the project and run it as a junit test. Eclipse will find all the tests and run them

Did you select the right package in the New -> Other > JUnit Test Suite menu ? By selecting a package with the "Browse..." button, you should see your test classes.

You can run all the tests directly with Run As > JUnit Test on the project but if you have many test classes it is recommended to use a Test Suite to regroup them (ex: slower tests, tests for a certain part of the program, etc.).

Take a look at this post to learn more about JUnit tests grouping.

Same happened to me and the explanation is quite simple: you've written your tests using JUnit Jupiter .

在此输入图像描述

However, JUnit Test Suite Wizard let's you pick only these 2 types of suites: JUnit3 or JUnit4 .

在此输入图像描述

Refactoring your tests to comply JUnit3 or JUnit4 will make them visible in JUnit Test Suite wizard.

Just group junit test cases using package. It is more reliable to check the counts of success and failure of each test cases.

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