简体   繁体   中英

Maven TestNG - unable to specify test suite from command line

I'm trying to run my tests from the command line by specifying the test suite from the command line. In my pom file, it says "Cannot resolve symbol 'suiteXmlFile' (for ${suiteXmlFile). It works if I specify the name of WebCheckout.xml in the pom file, butI want to be able to run it from the command line like this:

mvn clean test -Dsurefire.suiteXmlFiles=WebCheckout.xml

I've been following this tutorial:

http://www.seleniumeasy.com/maven-tutorials/choose-selected-testng-xml-files-to-execute-using-maven

My pom file is configured as follows:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12.4</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>

Please can someone tell me where I'm going wrong.

This is an issue affecting 2.12 (and possible prior versions), so just use a surefire plugin version >= 2.18.1 where it has been fixed. I tried 2.21.0 (latest ATM) and it works as expected (although I have my XMLs in the test/resources dir so I had to specify -Dsurefire.suiteXmlFiles=src\test\resources\test.xml )

I had the same issue and just updating the version of surefire plugin did not helped - i needed to add to my pom following property as well

<properties>
        <suiteXmlFile>SOME_DEFAULT_VALUE.xml</suiteXmlFile>
 </properties>

after that the error in pom file disappeared and I could pass a parameter through the command line

Try this one

<properties>
<suiteXmlFile>TestData</suiteXmlFile>
</properties>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM