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 Answer(s)

    Hi Laxmi

    i guess you should go with Testng.xml as you can define your test cases there, there order,there groups  although i have no idea about  TestNG>Convert to TestNG  but i guess using testng.xml to control your test cases is better

    and you can define testng.xml in your pom this way

    
    
    		
    
    
    
    Vice Professor Answered on April 22, 2015.

    ankit can u please explain code u added for “you can define testng.xml in your pom this way”
    I don’t know how to do this

    on April 24, 2015.
    Add Comment

    These are new features provided by eclipse
    we can convert a java project to maven
    we can convert junit classes/methods in maven project to testng framework
    we can create directly a maven project using eclipse and add we can dependency in POM and recompile using eclipse it actually runs command
    mvn clean install

    You can use eighter option both are same, it does nothing but it create a testng.xml file for you based on ur project

    Supporter Answered on April 24, 2015.
    Add Comment

    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.