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
Output of tree
command:
C:.
├───.idea
│ └───libraries
├───META-INF
├───out
│ └───artifacts
├───resources
│ └───leanftjar
├───RunResults
│ └───Resources
│ ├───Snapshots
│ └───User
├───src
│ ├───main
│ │ ├───java
│ │ │ ├───hu
│ │ │ │ └───mysoft
│ │ │ ├───jar
│ │ │ │ └───META-INF
│ │ │ ├───META-INF
│ │ │ ├───unittesting
│ │ │ └───utils
│ │ └───resources
│ └───test
│ └───java
│ └───test
├───target
│ ├───classes
│ │ ├───hu
│ │ │ └───mysoft
│ │ ├───leanftjar
│ │ ├───unittesting
│ │ └───utils
│ ├───generated-sources
│ │ └───annotations
│ ├───generated-test-sources
│ │ └───test-annotations
│ ├───maven-status
│ │ └───maven-compiler-plugin
│ │ └───compile
│ │ └───default-compile
│ └───test-classes
│ └───test
└───test-output
├───All Test Suite
├───junitreports
└───old
└───All Test Suite