Reputation: 54094
org.junit.Assert.
has deprecated junit.framework.Assert
My question is how do I create a Test Suite in Eclipse if my JUnit classes do not extend a TestCase
?
When I try to create new Test Suite in Eclipse my classes do not appear in the select box and I imagine this is because they don't extend a TestCase
.
I thought that with the new org.junit
I can just use annotation and not extend TestCase
Upvotes: 4
Views: 12518
Reputation: 7622
JUnit 4, which is bundled with eclipse doesn't use the old way of testing, where your testcases and testsuites used to extend classes.
JUnit 4 relies on annotations.
Just right click your project, select "new->other" go to "Test case", select JUnit 4, select the class under test, the methods under test and you've got your test case. For a test suite, right click the project, select "other", go to "test suite", and select the test case you created in the previous step... or more test cases.
Upvotes: 2
Reputation: 2291
The following code will create a test suite with Junit4. You can then just run this in Eclipse as a Junit test case. Obviously the TestClasses need to contain methods annotated with @Test otherwise no tests will actually run for the suite.
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({TestClass1.class, TestClass2.class})
public class TestSuite {
//nothing
}
Upvotes: 11