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
.
That kind of J icon filled to a "bubble" means that Eclipse doesn't recognize your project as a Java project, and therefore doesn't provide Java options such as Run as JUnit. Try reimporting the project as a Java Project.
The error occurs because the JUnit library has not been configured for the project, but can be resolved using the following steps. 1. Right click on the Java project and select Build Path > Configure Build Path.
Open eclipse → right click on project and click on property > Build Path > Configure Build Path and add the junit-4.10. jar in the libraries using the button Add External Jar. We assume that your Eclipse has inbuilt JUnit plugin.
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With