【发布时间】:2015-06-19 19:14:09
【问题描述】:
我为执行 TestNG 套件 文件配置了我的 pom.xml。
执行的文件作为参数传递给 Maven。
但问题是当我从控制台运行时:
mvn integration-test -Dmain-suite=${circuit-suite}
一切正常,测试执行开始。
但是当我尝试从Git Bash 运行它时,我得到了错误:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.892 s
[INFO] Finished at: 2015-04-14T11:30:20+02:00
[INFO] Final Memory: 31M/363M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18:test (default-test) on project webClientI
MPAutomation: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18:test failed: There was an e
rror in the forked process
[ERROR] org.apache.maven.surefire.testset.TestSetFailedException: Suite file d:\HOME\IdeaProjects\webclient_suite\suite is not a valid file
[ERROR] at org.apache.maven.surefire.testng.TestNGXmlTestSuite.locateTestSets(TestNGXmlTestSuite.java:116)
[ERROR] at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:83)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
[ERROR] -> [Help 1]
我无法调查为什么它会搜索 suite 作为套件文件。
这里是 pom sn-p:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<smoke-suite>${basedir}/src/test/resources/webClientIMPSuites/SmokeSuiteCI.xml</smoke-suite>
<circuit-suite>${basedir}/src/test/resources/webClientIMPSuites/CircuitUITests.xml</circuit-suite>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
<executions>
<execution>
<id>default-test</id>
<phase>integration-test</phase>
<configuration>
<suiteXmlFiles>
<suiteXmlFiles>${main-suite}</suiteXmlFiles>
</suiteXmlFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我将 testng 套件文件作为参数传递给 Maven。可执行的 suite 文件保存为 pom 的属性。在这种情况下,它的值为:
${basedir}/src/test/resources/webClientIMPSuites/CircuitUITests.xml
为什么会出现这种奇怪的行为?
如何解决它。并在Git Bash 处执行。
【问题讨论】:
-
你的 shell(命令行)中 ${circuit-suite} 的值是多少?
-
@WalterA 它是 pom 属性 -
${basedir}/src/test/resources/webClientIMPSuites/CircuitUITests.xml -
我以为你用命令行
mvn integration-test -Dmain-suite=${circuit-suite}否决了它。 -
@WalterA 我明确地说我通过
main-suite传递的属性。此套件文件保存为 pom 属性。
标签: java git bash maven testng