简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM