2015-04-14 38 views
0

我配置了我的pom.xml執行TestNG套件文件。從Git Bash失敗運行Maven目標

已執行的文件作爲參數傳遞給Maven。

但麻煩的是,當我從控制檯運行:

MVN集成測試-Dmain套房= $ {電路套房}

它工作正常,測試開始執行。

但是,當我試圖從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片段:

<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也執行。

+0

你的shell(commandline)中$ {circuit-suite}的值是多少? –

+0

@WalterA它是POM屬性 - '$ {basedir}/src/test/resources/webClientIMPSuites/CircuitUITests.xml' –

+0

我以爲你用命令行'mvn integration-test -Dmain-suite = $ {circuit-套房}'。 –

回答

1

您可能有一個shell /命令行變量circuit-suite,該變量擴展爲d:\HOME\IdeaProjects\webclient_suite\suite。嘗試

mvn integration-test -Dmain-suite=\${circuit-suite} 

注意在$之前的反斜線。這告訴BASH單獨離開這個變量並將它傳遞給Maven。

相關問題