Testng Executes Multiple Suite

We know the configuration file of testng, there can only be one suite in an .xml, so what if you want to set up multiple suites? At this time we need to use the testng tag .

Let’s talk about an example I made. First, I have two suites, one is UItest.xml and the other is APITest.xml. The code is as follows:

UITest.xml:






<class name="testcase.CheckLink">class>


APITest.xml:






<class name="APITestcase.CheckWeather">class>


At this time, I also talk about the detours I have taken. My project uses maven, and maven uses when linking testng files. , As shown in the figure below:



src/test/resources/testng.xml

Initially I thought that as long as one more was configured, it was fine. After trying it, I found that it was not feasible. You can see from the execution log that it has been After executing all the test classes, but the html test report only shows the test results of one suite, which is counterproductive, so I gave up this configuration method. Of course, this is also probably because maven+testng+reportng is related to the configuration. I don’t Understand the cause, I will update this method if it works in the future.

Let’s get back to the point. Finally, for the sake of brevity of the code, I also use a testng.xml to integrate APITest.xml and UITest.xml, as shown in the following figure:








Then just associate testng.xml in maven, and the final execution result is shown in the figure below:

Share a picture






<class name="testcase.CheckLink">class>







<class name="APITestcase.CheckWeather">class>




src/test/resources/testng.xml








Leave a Comment

Your email address will not be published.