8

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.

djechlin
  • 59,258
  • 35
  • 162
  • 290
DevCoder
  • 526
  • 2
  • 5
  • 14
  • 1
    you should post your code.... your question is no help without knowing what your doing... – devHead Sep 28 '12 at 16:43
  • Can you list the directories you're using for your build and the XML files? Also, when you reference the files, are you using relative or absolute paths? – DanM7 Sep 28 '12 at 16:45
  • Have you read the [documentation](http://maven.apache.org/plugins/maven-surefire-plugin/examples/testng.html#Using_Suite_XML_Files)? – Frank Pavageau Sep 28 '12 at 16:59
  • Remember to accept this answer if helpful. – Gray Jan 04 '18 at 15:23

2 Answers2

6

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>
Community
  • 1
  • 1
Gray
  • 115,027
  • 24
  • 293
  • 354
  • 1
    thanks! that worked fine for me. But 1 most important thing I've noticed- no matter what folder testng.xml is placed, POM.xml should exactly replace its location. And it works :) Thanks again. – eugene.polschikov Jun 03 '14 at 14:30
0

It does not matter where you put as long as you specify the path in your maven pom.xml under maven-surefire-plugin

Mikey
  • 380
  • 4
  • 15