user9463130
user9463130

Reputation:

How do I execute multiple JUnit test suites from a single class?

I've tried to search on google, but I keep getting the same answer which is to use the following code:

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

@RunWith(Suite.class)
@SuiteClasses({FirstTest.class,SecondTest.class,ThirdTest.class})
public class RunTestSuite {
}

However when I attempt to use this code in my program, I get multiple errors. All of them say the same thing: Access restriction: The type is not API.

Is there a way to fix this? Or another method altogether that I can use to execute multiple test suites?

Upvotes: 6

Views: 2291

Answers (1)

Kaushal28
Kaushal28

Reputation: 5557

An alternative of this approach can be running all test cases of entire project. You can do this by simply right-clicking the project -> Run As JUnitTest.

If you want to ignore some of the test cases you can use @ignore with it. Hope this helps. I know this is not the actual answer, but just a work around.

Upvotes: 2

Related Questions