Tag: plugin

当Mavenunit testing失败时,如何让Jenkins构build失败?

我正在使用Jenkins,Maven 3.1和Java 1.6。 我有以下的目标和选项在jenkins设立的以下Maven工作… clean install -U -P cloudbees -P qa 下面是我的pom.xml surefireconfiguration… <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.17</version> <configuration> <reuseForks>true</reuseForks> <argLine>-Xmx2048m -XX:MaxPermSize=512M </argLine> <skipTests>false</skipTests> </configuration> </plugin> 但是,当我的unit testing失败时,Jenkins控制台输出仍然表示“BUILD SUCCESS”,并且构build标记为“unstable”而不是彻底失败。 如何在Jenkins中configuration(或Maven,如果它的结果​​是什么),这样如果任何unit testing失败,我的构build失败(不会变得不稳定或通过)? 以下是控制台输出的内容 17:08:04 MyProjectOrganizationControllerTest.testRecoverFromError » IllegalState Failed to… 17:08:04 MyProjectOrganizationControllerTest.testVerifyDistrictListPopulated » IllegalState 17:08:04 MyProjectOrganizationControllerTest.testUpdateSchool » IllegalState Failed to loa… 17:08:04 MyProjectOrganizationControllerTest.testDeleteSchool » IllegalState Failed to loa… […]

使用Hamcrest 1.3和JUnit 4.11的NoSuchMethodError

另一个JUnit&Hamcrest组合的NoSuchMethodError实例。 出错代码: assertThat(dirReader.document(0).getFields(), hasItem( new FeatureMatcher<IndexableField, String>(equalTo("Patisnummer"), "Field key", "Field key") { @Override protected String featureValueOf(IndexableField actual) { return actual.name(); } } )); IndexerTest.java中的注释行152-157(commit ac72ce ) 导致NoSuchMethodError(请参阅http://db.tt/qkkkTE78获取完整的输出): java.lang.NoSuchMethodError: org.hamcrest.Matcher.describeMismatch(Ljava/lang/Object;Lorg/hamcrest/Description;)V at org.hamcrest.FeatureMatcher.matchesSafely(FeatureMatcher.java:43) at org.hamcrest.TypeSafeDiagnosingMatcher.matches(TypeSafeDiagnosingMatcher.java:55) at org.hamcrest.core.IsCollectionContaining.matchesSafely(IsCollectionContaining.java:25) at org.hamcrest.core.IsCollectionContaining.matchesSafely(IsCollectionContaining.java:14) at org.hamcrest.TypeSafeDiagnosingMatcher.matches(TypeSafeDiagnosingMatcher.java:55) at org.junit.Assert.assertThat(Assert.java:770) at org.junit.Assert.assertThat(Assert.java:736) at indexer.IndexerTest.testIndexContainsField(IndexerTest.java:152) 设置: JUnit 4.11 Hamcrest 1.3 使用Maven的surefire插件(版本2.14),它使用了JUnitCoreProvider Java 7(OpenJDK) 看到pom (commit […]

在maven中不能使用jacoco JVM参数和surefire JVM参数

我正在使用jacoco插件的maven生成代码覆盖率度量。 我在使用jacoco插件所需的java选项configurationsurefire插件时遇到一些困难。 我已经看到了堆栈溢出已经有一些答案,但有些不适合我。 我有一个多模块项目,我的一个模块configurationsurefire插件如下: foo/pom.xml : <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <argLine>-XX:MaxPermSize=512m</argLine> </configuration> </plugin> </plugins> 这按预期工作。 现在我想包含jacoco来获取代码覆盖度量,所以我添加了一个CodeCoverageconfiguration文件来处理所有的jacococonfiguration: parent/pom.xml : <profile> <id>CodeCoverage</id> <build> <pluginManagement> <plugins> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <executions> <execution> <id>jacoco-initialize</id> <goals><goal>prepare-agent</goal></goals> <configuration> <propertyName>surefire.argLine</propertyName> </configuration> … </execution> <executions> </plugin> </plugins> </pluginManagement> </build> </profile> 在这里可以看到,如果指定了CodeCoverageconfiguration文件,那么将jacoco插件configuration为使用surefire.argLine属性,并且该属性用于configurationargLine插件的argLine 。 然后,我更新了foo模块的pom.xml文件,以使用由jacoco插件生成的surefire.argLine属性: foo/pom.xml : <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <argLine>${surefire.argLine} -XX:MaxPermSize=512m</argLine> </configuration> […]