vendredi 18 mai 2018

Execute tests sequentially in TestNG

I have multiple test classes, which should be executed sequentially. I created testng.xml file with following content.

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="MyTestSuite1" verbose="2" parallel="methods" thread-count="1">
    <listeners>
        <listener class-name="utils.TestNGListener"></listener>
    </listeners>

    <test name="Regression" parallel="false" verbose="2">
        <classes>
            <class name="test.LoginTest" />
            <class name="test.ClearTest" />
            <class name="test.SendMessageTest" />
        </classes>
    </test>
</suite>

I created main() method for project to provide entry point.

public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException {
    TestNG testNG = new TestNG();

    String xmlFileName = "testng.xml";
    List<XmlSuite> suite = (List<XmlSuite>)(new Parser(xmlFileName).parse());
    testNG.setXmlSuites(suite);

    testNG.run();
}

I am not sure, how to execute test suite in specified order, got error message.

Exception in thread "main" org.testng.TestNGException: Cannot find class in classpath: test.LoginTest

Aucun commentaire:

Enregistrer un commentaire