Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In which directory I have to place testng.xml?

Tags:

java

maven

testng

I'm doing one project in which I have to perform automation testing. For this purpose I'm using Testng framework.

I am giving testng.xml as input file and some method will consume it, however right now my reader method is not able to detect the file.

In which directory I to place my testng.xml file..... and is there any maven specification I have to make in pom.xml for detecting that testng.xml file is there and they have to read it.

like image 487
DevCoder Avatar asked Sep 28 '12 16:09

DevCoder


People also ask

Where do I put TestNG xml?

Step1: Right-click on the Project folder, go to New and select 'File' as shown in the below image. Step 2: Add the file name as 'testng. xml' as shown in the below image and click on the Finish button. Step 3: Now you can add the below XML code in your testng.

What is correct TestNG xml format?

TestNG. xml file is an XML file which contains all the Test configuration and this XML file can be used to run and organize our test. TestNG eclipse plugin can be used to automatically generate testng. xml file so no need to write from scratch.


1 Answers

In which directory I to place my testng.xml file.....

I suspect that the testng.xml file should be put at the top of your classpath. If you are using maven then a good place for it would be src/test/resources/testng.xml. See this example:

How to call testng.xml file from pom.xml in Maven

is there any maven specification I have to make in pom.xml for detecting that testng.xml file is there and they have to read it.

I'm not 100% sure about this. In looking at the above example it looks like something like the following is recommended:

<plugin>
    <groupId>org.apache.maven.plugin</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.12</version>
    <configuration>
       <suiteXmlFiles>
           <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
       </suiteXmlFiles>
    </configuration> 
</plugin>
like image 155
Gray Avatar answered Oct 12 '22 02:10

Gray