Reputation: 521
I am trying to create a junit test suite that will run all of the test suites within the application... - this is what I have and as far as I can find it should work but it keeps telling me that no tests are found.
import static org.junit.Assert.*;
import org.junit.Test;
/**
* @author Jason
*
*/
@Test
public class applicationTest extends TestCase {
public applicationTestSuite(String name) {
super(name);
}
public static Test suite() {
TestSuite suite = new TestSuite("ApplicationTestSuite");
suite.addTest(domain.AllDomainTests.suite());
suite.addTest(services.AllServicesTests.suite());
suite.addTest(business.AllBusinessTests.suite());
return suite;
}
}
An example of one of the test suites it should be running -
package business;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({ ItemMgrTest.class })
public class AllBusinessTests {
}
Upvotes: 1
Views: 410
Reputation: 61715
You can specify Suite classes in your @SuiteClasses
, for instance:
@RunWith(Suite.class)
@SuiteClasses({ AllBusinessTests.class })
public class AllTests {
}
The suite() method is a JUnit 3 thing, and won't find any methods or tests in your suite, because you're using JUnit 4.
Upvotes: 0
Reputation: 240956
You need to mark @Test
annotation on test method
API Document
The Test annotation tells JUnit that the public void method to which it is attached can be run as a test case. To run the method, JUnit first constructs a fresh instance of the class then invokes the annotated method. Any exceptions thrown by the test will be reported by JUnit as a failure. If no exceptions are thrown, the test is assumed to have succeeded [...]
Upvotes: 1