RE: What is difference between adding a xml file to project named- TestNg.xml & Project>TestNG>Convert to TestNG?

Hi Guys,

I have come across 2 methods of converting project into TestNG:
1. Create a new Maven project (with simple archtypes)
2. Then write your methods & use @Test while doing so.
3. Then add a XML file named TestNG.xml
Ref: http://www.toolsqa.com/selenium-webdriver/testng-testsuite/
 or
1. Create a new Maven project (with simple archtypes)
2. Then write your methods & use @Test while doing so.
3. Right click on project
TestNG>Convert to TestNG

Kindly advise which option is better?

Also, please put a light on How to call TestNGSuite from POM.xml

Many thanks

Add Comment
3 Answers

To elaborate more on my problem or dilema:

> I started project as a Simple archtype MVN project
> Then started using TestNG dataProvider annotation
> Later switched to TestNG.xml file based data feeding (calls to detailed test data files kept elsewhere)
Which looks something like:

  • ..
  • <test name=”Test30_2″>
    <parameter name=”TestCaseId” value=”TC30_2″ />
    <classes>
    <class name=”com.SAPAutomation.TestStaging.SAPAutomationTestByXML” />
    </classes>
    </test>

    <test name=”Test31_1″>
    <parameter name=”TestCaseId” value=”TC31_1″ />
    <classes>
    <class name=”com.SAPAutomation.TestStaging.SAPAutomationTestByXML” />
    </classes>
    </test>

    <test name=”Test31_2″>
    <parameter name=”TestCaseId” value=”TC31_2″ />
    <classes>
    <class name=”com.SAPAutomation.TestStaging.SAPAutomationTestByXML” />
    </classes>
    </test> –>

> Then I included this file into POM.xml, as below:

  • <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <version>2.17</version>
    <configuration>
    <downloadSources>true</downloadSources>
    <downloadJavadocs>true</downloadJavadocs>
    </configuration>
    </plugin>

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.14.1</version>
    <configuration>
    <suiteXmlFiles>
    <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
    </suiteXmlFiles>
    </configuration>
    </plugin>

> But, when I run the POM.XML testng runs 0 tests & terminats.

I might have done some silly / fundamental mistake over last few months.
Note: – Standalone run of TestNG.xml runs all the test sequentially, as intended.

Could you please advise, how to run the TestNG.xml correctly.??

Many Thanks

Train Answered on April 29, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.