gpt4 book ai didi

junit - IntelliJ 运行单元测试时出错 : Could not find or load main class ${surefireArgLine}

转载 作者:行者123 更新时间:2023-12-03 05:37:53 25 4
gpt4 key购买 nike

在 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 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的值?

最佳答案

我遇到了同样的问题,我想我在 vertx-issue tracker 上找到了解决方案.

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

这对我来说适用于 IntelliJ 14.1.6 和 mvn 3.3.9首选项 -> 构建、执行、部署 -> 构建工具 -> Maven -> 运行测试

适用于 IntelliJ 2019 及更高版本设置->构建、执行、部署->构建工具->Maven->运行测试

取消选中argLine

关于junit - IntelliJ 运行单元测试时出错 : Could not find or load main class ${surefireArgLine},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24115142/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com