program tip

단위 테스트 실행시 IntelliJ 오류 : $ {surefireArgLine} 주 클래스를 찾거나로드 할 수 없습니다.

radiobox 2020. 12. 6. 21:24
반응형

단위 테스트 실행시 IntelliJ 오류 : $ {surefireArgLine} 주 클래스를 찾거나로드 할 수 없습니다.


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 플러그인) 통합이 다르게 작동하도록 구성해야합니다.

다음을 통해 수행하십시오. Preferences -> Build,Execution,Deployment -> Build Tools -> Maven -> Running Tests

선택 취소 argLine

이것은 mvn 3.3.9와 함께 IntelliJ 14.1.6에서 나를 위해 작동합니다.


surefire-plugin 버전을 2.10으로 변경하고 제거하여 Netbeans에서이 오류를 수정할 수있었습니다.

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

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

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


Was looking for this and found this project "fix" it in this thread

Basically define your jacocoArgLine var name as empty project property. Then in surefire configuration use @{jacocoArgLine} instead of dollar prefix.

참고URL : https://stackoverflow.com/questions/24115142/intellij-error-when-running-unit-test-could-not-find-or-load-main-class-suref

반응형