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

编程入门 行业动态 更新时间:2024-10-25 14:28:10
本文介绍了运行单元测试时出现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}

本文发布于:2023-11-25 05:50:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628569.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元测试   加载   错误   surefireArgLine   IntelliJ

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!