Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Test Suite in Eclipse under org.junit

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

like image 903
Cratylus Avatar asked Dec 13 '22 06:12

Cratylus


1 Answers

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
}
like image 187
Kingamajick Avatar answered Jan 05 '23 17:01

Kingamajick