IntelliJ Error when running unit test: Could not find or load main class ${surefireArgLine}

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

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

This works for me in IntelliJ 14.1.6 with mvn 3.3.9 Preferences -> Build,Execution,Deployment -> Build Tools -> Maven -> Running Tests

For IntelliJ 2019 and above Settings-> Build,Execution,Deployment -> Build Tools -> Maven -> Running Tests

Uncheck argLine


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

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

from the maven-surefire-plugin configuration. Instead i have created a property argLine that is picked automatically by 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 single files and test methods. And Code Coverage is working as expected.


Update of pom.xml solved my problem.

<argLine>${surefire.argLine}</argLine>

Complete plugin info in 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> -->