在IntelliJ中运行单元测试时,我会得到以下错误: Error:未能找到或加载主类${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设置值?
发布于 2016-02-13 10:11:24
我也遇到了同样的问题,我想我在vertx问题跟踪器上找到了解决方案。
简而言之,您必须配置您的IntelliJ Maven (尽人皆知的插件)集成,使其行为有所不同。
这适用于我在IntelliJ 14.1.6中使用MVN3.3.9 Preferences -> Build,Execution,Deployment -> Build Tools -> Maven -> Running Tests
IntelliJ 2019年及以上Settings-> Build,Execution,Deployment -> Build Tools -> Maven -> Running Tests
取消检查argLine
发布于 2015-12-04 11:05:30
我能够修复Netbeans中的此错误,方法是将强制插件版本更改为2.10并删除
<argLine>-Xmx1024m -XX:MaxPermSize=256m ${argLine}</argLine>
从maven-surefire-plugin配置。相反,我已经创建了一个属性argLine,该属性由“尽职尽责”自动选择。
<properties>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
</plugin>
现在,我可以运行和调试单个文件和测试方法。代码覆盖正在按预期工作。
发布于 2018-05-08 14:16:51
pom.xml的更新解决了我的问题。
<argLine>${surefire.argLine}</argLine>
在pom.xml中完成插件信息
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<parallel>classes</parallel>
<threadCount>10</threadCount>
<workingDirectory>${project.build.directory}</workingDirectory>
<jvm>${env.JDK1_8_HOME}\bin\java</jvm>
<argLine>${surefire.argLine}</argLine>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.18.1</version>
</dependency>
</dependencies>
</plugin> -->
https://stackoverflow.com/questions/24115142
复制相似问题