运行单元测试时出现IntelliJ错误:无法找到或加载主类$ {surefireArgLine} [英] IntelliJ Error when running unit test: Could not find or load main class ${surefireArgLine}

查看:219
本文介绍了运行单元测试时出现IntelliJ错误:无法找到或加载主类$ {surefireArgLine}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I get the following error when running Unit tests in IntelliJ: Error: Could not find or load main class ${surefireArgLine}. I am using maven and in pom.xml I have:

<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 the path to the file which contains the execution data.-->
                        <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                        <!--
                            Sets the name of the property containing the settings
                            for JaCoCo runtime agent.
                        -->
                        <propertyName>surefireArgLine</propertyName>
                    </configuration>
                </execution>
   ...

有人有类似的问题吗?如何为surefireArgLine设置值?

Did anyone have similiar problem? How to set value for surefireArgLine?

推荐答案

我遇到了同样的问题,我认为我在

I had the same problem and i think i found the solution on the vertx-issue tracker.

简而言之,您必须将IntelliJ Maven(surefire插件)集成配置为不同的行为.

In short you have to configure your IntelliJ Maven (surefire plugin) integration to behave differently.

通过以下方式执行此操作: Preferences -> Build,Execution,Deployment -> Build Tools -> Maven -> Running Tests

Do this via: Preferences -> Build,Execution,Deployment -> Build Tools -> Maven -> Running Tests

取消选中argLine

这在IntelliJ 14.1.6和mvn 3.3.9中对我有效

This works for me in IntelliJ 14.1.6 with mvn 3.3.9

这篇关于运行单元测试时出现IntelliJ错误:无法找到或加载主类$ {surefireArgLine}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆