我有一個Maven TestNG項目,並且正在嘗試將幾個命令行參數傳遞到testng.xml文件中。Maven TestNG項目,將命令行參數傳遞給testng.xml文件
的的testng.xml文件看起來象下面這樣:
<suite name="Test Suite" parallel="classes" thread-count="100" >
<test name="VIP Tests">
<parameter name="browser" value="${browser}" />
<groups>
<run>
<include name="${test.scope}" />
</run>
</groups>
<packages>
<package name="com.tests.*" />
</packages>
</test>
</suite>
pom.xml文件看起來象下面這樣:現在
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Test_Project</groupId>
<artifactId>TP_X</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<resources>
<resource>
<directory>src/test/resources</directory>
</resource>
</resources>
<sourceDirectory>${src.dir}</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
,每次我試圖執行的Maven測試命令
mvn clean test -U -Dtest.scope=smoke -Dbrowser=chrome
我在命令行中得到以下錯誤:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project VIP_QE: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: There was an error in the forked process
[ERROR] java.util.regex.PatternSyntaxException:
[ERROR] Illegal repetition near index 0
[ERROR] ${test.scope}
有人可以幫忙嗎?我一直堅持這個問題約一個星期。
我使用Maven的命令是「MVN乾淨的測試-U -Dtest.scope =煙-Dbrowser =鉻」。抱歉遺漏了瀏覽器參數。 – jsmith
@nullpointer謝謝。 – jsmith