IntelliJ Error starting unit test: could not find or load the main class $ {surefireArgLine}

When running unit tests in IntelliJ, the following error appears: Error: Could not find or load the main class $ {surefireArgLine}. I use 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> ... 

Has anyone had a similar problem? How to set value for surefireArgLine?

+23
intellij-idea junit maven-surefire-plugin
Jun 09 '14 at 6:57
source share
3 answers

I found out that I have to run my test case from maven using mvn -Dtest = TestCircle test not directly from the IDE.

0
Jun 09 '14 at 7:16
source share

I had the same problem and I think I found a solution in the tracker with the vertx version .

In short, you need to configure the IntelliJ Maven (surefire plugin) integration to behave differently.

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

Uncheck argLine

This works for me on IntelliJ 14.1.6 with mvn 3.3.9

+62
Feb 13 '16 at 10:11
source share

I was able to fix this error in Netbeans by changing the surefire-plugin version to 2.10 and uninstalling

 <argLine>-Xmx1024m -XX:MaxPermSize=256m ${argLine}</argLine> 

from the maven-surefire-plugin configuration. Instead, I created the argLine property, which is automatically selected using surefire.

 <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> 

Now I can run and debug individual files and test methods. And Code Coverage works as expected.

+3
Dec 04 '15 at 11:05
source share



All Articles