4

This is my testng.xml file:

<suite name="Suite1" verbose="1" parallel="true" thread-count="5">
    <suite-files>
        <suite-file path="xml-files/live.xml"></suite-file>
        <suite-file path="xml-files/test.xml"></suite-file>
    </suite-files>
</suite>

I want to run both these xml and though it does start running but the problem is, it only runs single file(test.xml) two times. does anyone have idea why is it happening?

Update: Added pom, live and test.xml files

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.hiverqa</groupId>
<artifactId>hiverqa</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>hiverqa</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <suiteXmlFile>testng.xml</suiteXmlFile>
</properties>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20.1</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>



<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.8</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.3</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.twilio.sdk/twilio -->
    <dependency>
        <groupId>com.twilio.sdk</groupId>
        <artifactId>twilio</artifactId>
        <version>7.14.5</version>
    </dependency>


</dependencies>

live.xml

<parameter name="browser" value="chrome"></parameter>

<parameter name="isExtensionInstalled" value="true" />
<parameter name="profileEnvironment" value="Live" /> <!-- default is selenium browser,Use 'Test' for test environment -->
<test name="SM Onboarding with Extension Test">


    <classes>
        <class name="tests.Onboarding_NonMP_SM_WebSignUP" />
        <class name="tests.Onboarding_NonMP_SL_SignUP" />
        <class name="tests.Onboarding_MP_SM_Signup" />
    </classes>



</test> <!-- Test -->

test.xml

<parameter name="isExtensionInstalled" value="true" />
<parameter name="profileEnvironment" value="Test" /> <!-- default is selenium browser,Use 'Test' for test environment -->
<test name="SM Onboarding with Extension Test">


    <classes>
        <class name="tests.Onboarding_NonMP_SM_WebSignUP" />
        <class name="tests.Onboarding_NonMP_SL_SignUP" />
        <class name="tests.Onboarding_MP_SM_Signup" />
    </classes>



</test> <!-- Test -->

  • Can you add the some more code like All 3 xml files ? – NarendraR Oct 28 '17 at 4:47
  • @NarendraR I have only two xmls to run. the problem is that when i try to run these files, last xml runs multiple times. do you have any idea why? – pritesh Nov 3 '17 at 6:25
0

First of all you need to configure live.xml file and test.xml file in your pom.xml file using maven-surefire-plugin. You can do it in following way after your </dependencies> tag.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20.1</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>"xml-files/live.xml"</suiteXmlFile>
                    <suiteXmlFile>"xml-files/test.xml"</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>

Then next you can run your testng.xml as it is..

  • i've tried that too but it did not work. It runs test.xml(last suite file) multiple times. – pritesh Nov 3 '17 at 6:20
  • can you show your test.xml file live.xml file pom file and testng.xml file? – Sachintha Nov 3 '17 at 9:24
  • Please see updated question – pritesh Nov 3 '17 at 10:05
  • In your pom file you have configured your tesng.xml file two times, is there any reason for that? <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <suiteXmlFile>testng.xml</suiteXmlFile> </properties> and <configuration> <suiteXmlFiles> <suiteXmlFile>${suiteXmlFile}</suiteXmlFile> </suiteXmlFiles> </configuration> – Sachintha Nov 6 '17 at 3:08
  • Yes, its intended. Basically, i'm referring testng.xml file from <properties> tag. – pritesh Nov 8 '17 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.