简体   繁体   中英

Junit Test Runner with Suite

Is it possible to get a TestRunner to run a Test Suite that's been created programmatically?

The Block4JunitTestRunner for example takes the Suite class as the constructor argument. However, I can't do this since the Suite isn't a concrete Suite. I dynamically add TestCases to a TestSuite and now I need a TestRunner to run it so im able to get Junit report the test failures/success/errors as normal. (

Thanks.

SuiteRunner

BlockJunit4ClassRunnerForInstance

Example Suite

This suite runner requires that you provide a static method returning a list of test instances eg

public static List<Object> testInstances(){
    ArrayList<Object> objects = new ArrayList<Object>();
    ..
    return objects;
}

The original behaviour of the block runner is to create a new instance per test method, so you might need to do more work in the setup to keep the tests independent.

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