Scolytus
Scolytus

Reputation: 17177

JUnit: How to bundle @Test methods to a suite?

I have several classes each containing several methods annotated with @Test. The classes are not extending TestCase. Now I want to

Since the classes are no TestCases I can't just add them to a suite. Also extending TestCase is not an option because the test methods are just annotated and their names don't start with 'test'.

How can I do this?

Upvotes: 1

Views: 520

Answers (3)

Jeanne Boyarsky
Jeanne Boyarsky

Reputation: 12266

What Eugene posted works if you have a small number of classes. If you want all the tests in a certain package pattern, Classpath Suite lets you specify this with patterns instead of listing them all out.

Upvotes: 1

Chetter Hummin
Chetter Hummin

Reputation: 6837

You can set up run configurations for a project. Right click on your project. Then selecte 'Run as' -> 'Run configurations'. Within that you can select run all tests

Upvotes: 1

Eugene Kuleshov
Eugene Kuleshov

Reputation: 31795

Try this:

@RunWith(Suite.class)
@Suite.SuiteClasses({
  Test1.class,
  Test2.class,
  Test3.class,
  Test4.class
})
public class YourTestSuite {
}

Upvotes: 4

Related Questions