0

There are 4 classes with tests TestClass1, TestClasss2, TestClass3, TestClass4. You need to create 2 test suites, each of which will include 2 classes and run them in parallel using the Maven surefire plugin.

I created 2 xml files with the following content:

<suite name="TestSuite" verbose="1">
    <test name="Test">
        <classes>
            <class name="Tests.TestClass1">
            </class>
            <class name="Tests.TestClass2">
            </class>
        </classes>
    </test>
</suite>

and

<suite name="TestSuite1" verbose="1">
    <test name="Test1">
        <classes>
            <class name="Tests.TestClass3">
            </class>
            <class name="Tests.TestClass4">
            </class>
        </classes>
    </test>
</suite>

Also added to pom.xml inmaven-surefire-plugin the following:

<configuration>
       <suiteXmlFiles>
           <suiteXmlFile>Testng.xml</suiteXmlFile>
           <suiteXmlFile>Testng1.xml</suiteXmlFile>
       </suiteXmlFiles>
       <parallel>suite</parallel>
       <perCoreThreadCount>false</perCoreThreadCount>
       <threadCount>2</threadCount>
</configuration>

Next, I run the project with the command mvn clean test, the project is going to, but the tests do not start. Where was I wrong?

UPD:

The project is building, but the tests do not start

The file testng.xml is located in the root folder

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running TestSuite
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.469 sec - in T
estSuite

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.288 s
[INFO] Finished at: 2018-08-27T15:52:21+03:00
[INFO] ------------------------------------------------------------------------
Pavel Bobrov
  • 1
  • 1
  • 2
  • Please share the error log if available, and also make sure that Testng.xml file is in the proper location. In the above code, it is assumed that the Testng.xml is in the root project folder – Bhargav Marpu Aug 27 '18 at 11:53
  • Updated description – Pavel Bobrov Aug 27 '18 at 12:03
  • By the way. If you do not specify the path to xmlSuiteFile in pom.xml - there is no error. The project build passes correctly – Pavel Bobrov Aug 27 '18 at 12:04
  • The error seems to be different, error some where either in dependency management or sure-fire, This has nothing to do with the testng.xml. Please refer https://stackoverflow.com/questions/36427868/failed-to-execute-goal-org-apache-maven-pluginsmaven-surefire-plugin2-12test/36429564 and also please ensure that there are no missing dependencies – Bhargav Marpu Aug 27 '18 at 12:15
  • I updated my maven plugin and this problem was solved. But now I ran into the next one. Look, plz, upd – Pavel Bobrov Aug 27 '18 at 12:57

1 Answers1

0

Try the following configuration:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.0</version>
    <configuration>
        <suiteXmlFiles>
            <file>src/test/resources/testng.xml</file>
            <file>src/test/resources/testng1.xml</file>
        </suiteXmlFiles>
        <properties>
            <property>
                <name>suitethreadpoolsize</name>
                <value>2</value>
            </property>
            <property>
                <name>surefire.testng.verbose</name>
                <value>10</value>
            </property>
        </properties>
    </configuration>
</plugin>
RocketRaccoon
  • 2,559
  • 1
  • 21
  • 30