2013-02-25 70 views
2

我有一个Jenkins平台,它调用maven进行单元测试(与surefire插件)和集成测试(与安全故障插件)。当集成测试出现错误时,Jenkins认为构建成功。这种行为是否正常?我宁愿它认为构建不稳定。更一般地说,你是否知道詹金斯如何阅读并解释构建的结果,将构建视为成功或不稳定?我在网上的某个地方读到,必须将故障安全报告重定向到肯定的报告路径。我做了id,但问题仍然存在。詹金斯+硒测试与故障安全插件

的pom.xml:

[...] 
    <plugin> 
     <artifactId>maven-surefire-plugin</artifactId> 
     <version>2.10</version> 
     <configuration> 
     <disableXmlReport>false</disableXmlReport> 
     </configuration> 
     <executions> 
     <execution> 
      <id>default-test</id> 
      <phase>test</phase> 
      <configuration> 
      <includes> 
       <include>**/tests/**</include> 
      </includes> 
      <excludes> 
       <exclude>**/testsIntegration/**</exclude> 
      </excludes> 
      </configuration> 
     </execution> 
     </executions> 
    </plugin> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-failsafe-plugin</artifactId> 
     <version>2.7.2</version> 
     <configuration> 
     <disableXmlReport>false</disableXmlReport> 
     <reportsDirectory>${basedir}/target/surefire-reports</reportsDirectory> 
     <includes> 
      <include>com/acelys/conventionsJuridiques/*.java</include> 
      <!-- ... inclure les tests Selenium --> 
     </includes> 
     </configuration> 
     <executions> 
     <execution> 
      <id>integration-test</id> 
      <phase>integration-test</phase> 
      <goals> 
      <goal>integration-test</goal> 
      </goals> 
      <configuration> 
      <includes> 
       <include>**/testsIntegration/**</include> 
      </includes> 
      <excludes> 
       <exclude>**/tests/**</exclude> 
      </excludes> 
      </configuration> 
     </execution> 
     </executions> 
    </plugin> 
[...] 

输出詹金斯:

[...] 
mojoStarted org.apache.maven.plugins:maven-failsafe-plugin:2.7.2(integration-test) 
[INFO] 
[INFO] --- maven-failsafe-plugin:2.7.2:integration-test (integration-test) @ BaseContrats --- 
[INFO] Failsafe report directory: C:\jenkins_home\workspace\Base Contrats EXT JS MAVEN\target\surefire-reports 

------------------------------------------------------- 
T E S T S 
------------------------------------------------------- 
Running com.acelys.conventionsJuridiques.testsIntegration.connexion.TestConnexion 

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 23.971 sec <<< FAILURE! 

Results : 

Failed tests: 
    testHomePage(com.acelys.conventionsJuridiques.testsIntegration.connexion.TestConnexion) 

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0 

[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent! 
mojoSucceeded org.apache.maven.plugins:maven-failsafe-plugin:2.7.2(integration-test) 
mojoStarted org.apache.tomcat.maven:tomcat6-maven-plugin:2.1-SNAPSHOT(tomcat-shutdown) 
[INFO] 
[INFO] --- tomcat6-maven-plugin:2.1-SNAPSHOT:shutdown (tomcat-shutdown) @ BaseContrats --- 
25 févr. 2013 09:32:08 org.apache.coyote.http11.Http11Protocol destroy 
INFO: Stopping Coyote HTTP/1.1 on http-8080 
25 févr. 2013 09:32:08 org.apache.catalina.core.ApplicationContext log 
INFO: Closing Spring root WebApplicationContext 
25 févr. 2013 09:32:08 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc 

mojoSucceeded org.apache.tomcat.maven:tomcat6-maven-plugin:2.1-SNAPSHOT(tomcat-shutdown) 
projectSucceeded BaseContrats:BaseContrats:1.0-SNAPSHOT 
sessionEnded 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 2:07.408s 
[INFO] Finished at: Mon Feb 25 09:32:08 CET 2013 
[INFO] Final Memory: 13M/51M 
[INFO] ------------------------------------------------------------------------ 
Projects to build: [MavenProject: BaseContrats:BaseContrats:1.0-SNAPSHOT @ C:\jenkins_home\workspace\Base Contrats EXT JS MAVEN\pom.xml] 
[JENKINS] Archiving C:\jenkins_home\workspace\Base Contrats EXT JS MAVEN\pom.xml to C:\jenkins_home\jobs\Base Contrats EXT JS MAVEN\modules\BaseContrats$BaseContrats\builds\2013-02-25_09-29-58\archive\BaseContrats\BaseContrats\1.0-SNAPSHOT\BaseContrats-1.0-SNAPSHOT.pom 
[JENKINS] Archiving C:\jenkins_home\workspace\Base Contrats EXT JS MAVEN\target\ConventionsJuridiques.war to C:\jenkins_home\jobs\Base Contrats EXT JS MAVEN\modules\BaseContrats$BaseContrats\builds\2013-02-25_09-29-58\archive\BaseContrats\BaseContrats\1.0-SNAPSHOT\BaseContrats-1.0-SNAPSHOT.war 
channel stopped 
Finished: SUCCESS 

回答

1

你可以看到Maven完成了成功。这将使詹金斯也取得成功。

为了将构建标记为不稳定,您需要一个构建后操作来分析测试结果并将构建标记为失败或不稳定。我建议您搜索Jenkins发布构建操作的更多细节,以处理测试结果并根据需要标记构建。

希望这会有所帮助。

0

您应该在您的构建中添加一个步骤:“发布Junit报告” 您将显示所有测试结果的图形,但如果测试失败,它也会设置正确的构建结果。

+0

在我的Jenkins Post-Build Choice列表中不存在选择“Publish Junit Report”。 – Clem 2013-02-25 12:55:31

2

根据the documentation

故障保护:验证验证应用程序的集成测试通过。

您需要将目标添加到Maven的故障保护,插件运行:

<goals> 
    <goal>integration-test</goal> 
    <goal>verify</goal> 
</goals> 

这将使詹金斯解释测试结果并标记生成不稳定。

0

在后构建操作下,Publish JUnit测试结果报告更改要搜索的报告XML。

这个假设是使用标准surefire和故障安全插件输出目录。

enter image description here

变化

enter image description here

0

故障安全插件的目标“集成测试”并不标志着建设成为错误时,测试失败。

您必须添加目标“验证”才能在插件执行中的“集成测试”之后运行。这将查找错误或失败并将构建标记为“错误”。然后Jenkins会看到Maven没有成功。