How to get Eclipse to recognize JUnit tests when creating a package?

When I use Eclipse to create a JUnit test suite, it does not detect any existing tests and warns "No test classes selected."

I started with a test class package (test / com /.../ package), and the package was selected. There are several JUnit tests also created using the same version of Eclipse, but there is no way to select them.

I am using JUnit 4.

Thanks!

+4
source share
3 answers

The set wizard currently only works with JUnit 3 tests, see the corresponding bugzilla entry .

+5
source

A Suite that works for me is:

import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; ... @RunWith(Suite.class) @SuiteClasses( { MyTest.class }) public class SeleniumSuite { ... } 

This helps if you want to run only a subset of the tests defined in the package. What tests do you name? Try refactoring them so that they are called either Test * .java or * Test.java.

+1
source

In Eclipse, you can simply right-click on the project / package you want to run the tests in and select Run as > Junit Test - you can avoid the need to programmatically create a test suite class completely.

0
source

All Articles