标签: maven-surefire-plugin

Maven surefire无法找到ForkedBooter类

最近来到一个新项目,我正在尝试编译我们的源代码.昨天一切都很好,但今天是另一个故事.

每次我在mvn clean install模块上运行时,一旦到达测试,它就会崩溃成一个错误:

[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ recorder ---
[INFO] Surefire report directory: /lhome/code/recorder/target/surefire-reports
[INFO] Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider
[INFO] parallel='none', perCoreThreadCount=true, threadCount=0, useUnlimitedThreads=false, threadCountSuites=0,     threadCountClasses=0, threadCountMethods=0, parallelOptimized=true

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Error: Could not find or load main class org.apache.maven.surefire.booter.ForkedBooter

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Run Code Online (Sandbox Code Playgroud)

后来:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project recorder: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: The forked VM terminated …
Run Code Online (Sandbox Code Playgroud)

java maven maven-surefire-plugin

210
推荐指数
10
解决办法
5万
查看次数

如何让maven-release-plugin跳过我的测试?

如何在不触发测试的情况下运行maven-release-plugin?

我试过了

-Dmaven.test.skip=true 
Run Code Online (Sandbox Code Playgroud)

-DskipTests 
Run Code Online (Sandbox Code Playgroud)

-DpreparationGoals=clean
Run Code Online (Sandbox Code Playgroud)

......但没有工作.

是的,我知道如果测试没有通过我不应该发布,但我无法控制让我的同事编写可靠的测试.

maven maven-release-plugin maven-surefire-plugin

175
推荐指数
3
解决办法
6万
查看次数

分叉的虚拟机终止而没有说再见.VM崩溃或System.exit调用

请帮我解决这个问题.我不完全理解日志中的错误意味着什么.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.749s
[INFO] Finished at: Thu Apr 24 10:10:20 IST 2014
[INFO] Final Memory: 15M/37M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.15:test (default-test) on project samples.simpleforwarding: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.15:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?
[ERROR] Command wascmd.exe /X /C ""C:\Program Files\Java\jdk1.7.0_55\jre\bin\java" -Xmx1024m -XX:MaxPermSize=256m -jar E:\OpenDayLight\controller\opendaylight\samples\simpleforwarding\target\surefire\surefirebooter53410321571238933.jar E:\OpenDayLight\controller\opendaylight\samples\simpleforwarding\target\surefire\surefire86076271125218001tmp E:\OpenDayLight\controller\opendaylight\samples\simpleforwarding\target\surefire\surefire_01846991116135903536tmp"
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full …
Run Code Online (Sandbox Code Playgroud)

java maven-surefire-plugin opendaylight

154
推荐指数
20
解决办法
12万
查看次数

防止单元测试但允许在Maven中进行集成测试

我有一个Maven构建,我使用SureFire插件来运行一些单元测试,而FailSafe插件则运行一些集成测试.我想要一种方法来运行FailSafe插件的测试.

对于我来说,在pom中添加不同的配置文件或任何东西并不是一个好的解决方案,因为它是一个多模块构建,我不想编辑每个模块的pom.

skip.testsmaven.test.skipskipTests它停止所有的测试,以及skipITs,其仅停止故障安全插件.

那么,Maven是否有一个命令行标志skipITs,而是具有"onlyITs"的功能?

integration-testing build maven maven-surefire-plugin maven-failsafe-plugin

138
推荐指数
5
解决办法
5万
查看次数

Surefire没有接受Junit 5测试

我用JUnit 5编写了一个简单的测试方法:

public class SimlpeTest {
    @Test
    @DisplayName("Some description")
    void methodName() {
        // Testing logic for subject under test
    }
}
Run Code Online (Sandbox Code Playgroud)

但是当我跑步时mvn test,我得到了:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running SimlpeTest
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Run Code Online (Sandbox Code Playgroud)

不知何故,surefire没有认出那个测试类.我pom.xml看起来像:

<properties>
    <java.version>1.8</java.version>
    <junit.version>5.0.0-SNAPSHOT</junit.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit5-api</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<repositories>
    <repository>
        <id>snapshots-repo</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        <releases>
            <enabled>false</enabled>
        </releases> …
Run Code Online (Sandbox Code Playgroud)

java junit maven maven-surefire-plugin junit5

104
推荐指数
7
解决办法
3万
查看次数

Maven Surefire和Maven Failsafe插件有什么区别?

Maven Surefire和Maven Failsafe插件有什么区别?

我在网上搜索但没有得到答案.

请有人帮助这个例子.

maven maven-surefire-plugin maven-failsafe-plugin

95
推荐指数
3
解决办法
3万
查看次数

如何在Maven中按类别运行JUnit测试?

使用JUnit 4.8和新@Category注释,有没有办法选择与Maven的Surefire插件一起运行的类别子集?

例如,我有:

@Test
public void a() {
}

@Category(SlowTests.class)
@Test
public void b() {
}
Run Code Online (Sandbox Code Playgroud)

我想按照以下方式运行所有非慢速测试:(注意-Dtest.categories由我组成......).

mvn test -Dtest.categories=!SlowTests // run non-slow tests
mvn test -Dtest.categories=SlowTests // run only slow tests
mvn test -Dtest.categories=SlowTests,FastTests // run only slow tests and fast tests
mvn test // run all tests, including non-categorized
Run Code Online (Sandbox Code Playgroud)

所以重点是我不想创建测试套件(Maven只是在项目中选择了非常方便的所有单元测试)并且我希望Maven能够按类别选择测试.我想我刚编了-Dtest.categories,所以我想知道是否有类似的设施我可以使用?

java junit categories maven maven-surefire-plugin

70
推荐指数
6
解决办法
5万
查看次数

运行单元测试时出现IntelliJ错误:无法找到或加载主类$ {surefireArgLine}

在IntelliJ中运行单元测试时出现以下错误:错误:无法找到或加载主类$ {surefireArgLine}.我正在使用maven,在pom.xml中我有:

<properties>
    ...
    <surefire.argLine />
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>apt-maven-plugin</artifactId>
            <version>1.1.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources/java</outputDirectory>
                        <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.17</version>
        <configuration>
             <!--Sets the VM argument line used when unit tests are run.-->
            <argLine>${surefire.argLine}</argLine>
        </configuration>
    </plugin>
  <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.1.201405082137</version>
            <executions>
                <!--
                    Prepares the property pointing to the JaCoCo runtime agent which
                    is passed as VM argument when Maven the Surefire plugin is executed.
                -->
                <execution>
                    <id>pre-unit-test</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                    <configuration>
                        <!--Sets …
Run Code Online (Sandbox Code Playgroud)

junit intellij-idea maven-surefire-plugin

61
推荐指数
2
解决办法
3万
查看次数

不能在maven中使用jacoco JVM args和surefire JVM args

我正在使用带有jacoco插件的maven 来生成代码覆盖率指标.我有在配置一些困难神火由所需的Java插件的选项jacoco插件.我已经在Stack Overflow上看到了一些关于此问题的答案,但有些东西对我不起作用.

我有一个多模块项目,我的一个模块配置了surefire插件,如下所示:

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>
Run Code Online (Sandbox Code Playgroud)

这按预期工作.

现在我想结合jacoco获取代码覆盖率的指标,所以我加了一个代码覆盖率配置文件,处理所有jacoco配置:

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>
Run Code Online (Sandbox Code Playgroud)

它是在这里看到的是,如果代码覆盖率指定配置文件,然后jacoco插件配置为使用surefire.argLine属性,该属性用于配置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> …
Run Code Online (Sandbox Code Playgroud)

maven maven-surefire-plugin jacoco

60
推荐指数
5
解决办法
4万
查看次数

如何在maven安装目标中跳过测试,同时在maven测试目标中运行它们?

我有一个多模块maven项目,在同一个文件夹(src/test/java)中集成了单元测试.集成测试标有@Category(IntegrationTest.class).我想最终得到以下设置:

  1. 如果我运行mvn install,我想要编译所有测试,但我不想执行任何测试.
  2. 如果我运行mvn test,我想要编译所有测试,但只执行单元测试.
  3. 如果我运行mvn integration-test,我想编译并执行所有测试.

重要的一点是,我希望在pom.xml没有任何额外命令行参数的情况下配置它.

目前我在我的父pom.xml中提出了以下设置,其中唯一的问题是#1,其中执行所有测试:

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${project.java.version}</source>
                    <target>${project.java.version}</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.14.1</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-junit47</artifactId>
                        <version>2.14.1</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <includes>
                        <include>**/*.class</include>
                    </includes>
                    <excludedGroups>cz.cuni.xrg.intlib.commons.IntegrationTest</excludedGroups>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.14.1</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-junit47</artifactId>
                        <version>2.14.1</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <groups>cz.cuni.xrg.intlib.commons.IntegrationTest</groups>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/*.class</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
Run Code Online (Sandbox Code Playgroud)

所有子模块在他们的pom.xml中都有以下插件配置,我认为它应该从父pom继承:

<build> …
Run Code Online (Sandbox Code Playgroud)

integration-testing maven maven-surefire-plugin maven-failsafe-plugin

56
推荐指数
5
解决办法
7万
查看次数