开发者

TestNG test reuse

Need some help thinking in TestNG terms. I have a large third party test suite written in TestNG and I'd like to be able to compose tests from it and run them from Intellij or Maven

Is it possible to compose tests together programmatically and still leverage the runners built into these other frameworks. In JUnit you could do this:

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class ExampleTest extends TestCase {

    public static Test suite() {
        final TestSuite suite = new TestSuite("suite");
        suite.addTestSuite(org.thirdparty.tests.FooTest.class);
        suite.addTestSuite(org.thirdparty.tests.BarTest.class);
        suite.addTestSuite(org.thirdparty.tests.BazTest.class);
        return suite;
    }
}

Can't seem to find an equivalent TestNG concept. I see there's an XmlSu开发者_开发技巧ite class that allows a suite to be programmatically created, but I see no way to hand this off to a test runner like Maven Surefire or Intellij.

Is it possible to do the simple and direct and create a Test which hands over the XmlSuite object or otherwise programmatically compose tests without also having to control the test runner?


It's a bit contrived, but you could always create an XmlSuite object, save the output of toXml() to a file and use the tag of Surefire to reference that file.

Does this answer your question?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜