Maven-surefire-plugin with TestNg: how to specify the directory in which xls files of test suites are stored?

I am currently working on a Maven project. I chose TestNg to run my unit tests. To run my unit tests in every Maven assembly, I added the maven-surefire-plugin to my pom.xml:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12</version>
            <configuration>
            <!-- Configuring the test suites to execute -->
                <suiteXmlFiles>
                     <suiteXmlFile>testsuite-persistence-layer.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>

In addition, I want to specify the tests that will be executed using TestNg TestSuiteXmlFile. For example, in my pom.xml, I configured the surefire plugin to run the tests defined in an XML file called "testuite-persistence-layer.xml".

The problem is that by default the surefire plugin seems to be looking for this XML file in the root of my project. How can I specify the directory where the surefire plugin should search for TestSuite XML files?

TestNg maven.testng.suitexml.dir, Surefire, , .

+3
1

, . xml, , .

<suiteXmlFile>c:/some/dir/testsuite-persistence-layer.xml</suiteXmlFile>

<suiteXmlFile>src/test/java/com/something/project/testsuite-persistence-layer.xml</suiteXmlFile>

, , , xmls. , ,

<suiteXmlFile>${xmlPath}/testSuite.xml</suiteXmlFile>

mvn test -DxmlPath=c:/some/path

, xmlPath - , , .

, xmlPath POM. , <project> .

<project ... >
    ...

    <properties>
        <xmlPath>c:/some/path</xmlPath>
    </properties>
        ...

    <build>
        ...
        <plugins>
        ...
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>${xmlPath}/testSuite.xml</suiteXmlFile>
                    </suiteXmlFiles>                                        
                    ...
                </configuration>
            </plugin>
        ...
        </plugins>
        ...
    </build>
    ...

</project>
+6

All Articles