I'm trying to pass the xml file path through command line on maven project, and nothing seems to work. I almost always get "Unknown lifecycle phase ".xml". error for every solution I found so far online.
This is how my plugin looks like:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${smoke}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
First of all, I wasn't able to save it if I didn't set it as a property of pom.xml, so I did it and hardcoded the path to my xml and it works. However, I can't seem to find a way to change that value while running mvn clean test ...
I tried things like these:
mvn clean test -Dsurefire.suiteXmlFile=smokeSuite.xml`
mvn clean test -Dsurefire.suiteXmlFile=src/test/smokeSuite.xml
mvn clean test -DsuiteXmlFile=smokeSuite.xml
mvn clean test -Dsurefire.smoke=smokeSuite.xml`
mvn clean test -Dsurefire.smoke=src/test/smokeSuite.xml
mvn clean test -Dsmoke=smokeSuite.xml
Almost always I get the error that .xml is an unknown lyfecycle phase, or when I add a space after suiteXmlFile, like this,
mvn clean test -Dsurefire.suiteXmlFile =src/test/smokeSuite.xml
I get that = is not a lyfecycle phase...
There's obviously something wrong with the command in the first place, but I cannot seem to find any documentation on how should the suiteXmlFile be passed down with mvn test ...
CodePudding user response:
Since you set it up as <suiteXmlFile>${smoke}</suiteXmlFile>
you need to pass the variable with -Dsmoke
and to make sure the value is parsed correctly you should wrap it in quotes to prevent it from being wrongly interpreted. So the full command should be
mvn clean test -Dsmoke="src/test/smokeSuite.xml"