2013-04-17 226 views
1

運行TestNG的我的測試套件有問題下面是堆棧跟蹤的錯誤,我看到對詹金斯

[INFO] --- maven-surefire-plugin:2.8.1:test (default-test) @ eselenium-smartpearsonplayer-pageobjects --- 
[INFO] Surefire report directory: c:\jenkins\workspace\MediaPlayerTest\target\surefire-reports 
There are no tests to run. 

我知道,這可能是由於什麼。所以讓我試着給你提供更多的信息,雖然這是一個很長的鏡頭,也許你可以提供幫助。 我使用硒webdriver 2.29來編寫測試。 我也在用maven構建。 我正在嘗試使用testng來配置我正在使用的測試。 我使用jenkins來運行maven項目,我試圖做「乾淨的驗證」,有時候是「乾淨的測試」,因爲我不知道兩者之間的區別。

本地我正在使用eclipse。本地我可以使用maven測試在maven上運行測試,並使用maven驗證。

這是我的朋友。

<!-- attempt to use surefire to run tests --> 
      <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.8.1</version> 
       <configuration> 
        <suiteXmlFiles> 
          <suiteXmlFile>src\test\resources\testng\TestBrowserPOC_Test.xml</suiteXmlFile> 
        </suiteXmlFiles> 
       </configuration> 
      </plugin> 
      <!-- end attempt --> 

同樣,當我在eclipse上進行maven驗證時,測試運行良好。

這是我的testng xml。

<!DOCTYPE Suite SYSTEM "http://testng.org/testng-1.0.dtd"> 
    <suite name="BrowserPOC_Tests"> 

     <!-- class does not exist --> 
     <!-- <test name="Demo Test"> <parameter name="url"  value="src/test/resources/testData/login.html"></parameter> 
      <groups> <run> <exclude name="errorDetector"></exclude> </run> </groups> 
      <classes> <class name="com.pearson.demotests.DemoTestIT" /> </classes>   </test> --> 
     <test name="POC test"> 
      <groups> 
       <run> 
        <include name="volumeTest"></include> 
       </run> 
      </groups> 
      <classes> 
       <class name="com.pearson.poc_tests.BrowserPOCIT" /> 
      </classes> 
     </test> 
</suite> 

現在我要嘗試改變我的XML名稱遵循「命名約定」,看看有沒有做任何事情。再次,測試在eclipse上運行良好,只是不在jenkins上。我不確定在這裏做什麼或者我需要什麼其他信息。我從這裏開始的步驟只是爲了得到詹金斯專家的更多幫助。

哦,我認爲我的測試xml的命名約定是正確的。 我也認爲我正在使用一個構建爲maven的自由式項目。 我應該使用「mvn clean test」而不是「clean test」嗎?

+1

您是否曾嘗試在沒有Eclipse的情況下運行'mvn test',即從命令行運行? –

+0

是否在工作區中提供了測試代碼? –

回答

0

我過去使用過maven fail-safe插件。以下是我的配置。你會運行mvn clean verify。總是推薦mvn clean,因爲它會在編譯和運行測試之前刪除目標目錄。

<properties> 
     <functionalSourceDirectory>src/itest</functionalSourceDirectory> 
</properties> 

<plugin> 
    <artifactId>maven-failsafe-plugin</artifactId> 
    <version>2.11</version> 
    <configuration> 
     <testSourceDirectory>${functionalSourceDirectory}</testSourceDirectory> 
     <suiteXmlFiles> 
     <suiteXmlFile>src/itest/resources/testng.xml</suiteXmlFile> 
     </suiteXmlFiles> 
    </configuration> 
    <executions> 
     <execution> 
      <id>verify</id> 
      <phase>verify</phase> 
      <goals> 
      <goal>verify</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 
1

謝謝大家。原來我的jenkins配置中有兩個存儲庫。詹金斯正在尋找錯誤項目中的測試。