Подтвердить что ты не робот

IntelliJ Ошибка при запуске unit test: не удалось найти или загрузить основной класс ${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?

4b9b3361

Ответ 1

Я узнал, что я должен запустить свой тестовый пример из maven с помощью   mvn -Dtest = TestCircle test не непосредственно из IDE.

Ответ 2

У меня была та же проблема, и я думаю, что нашел решение в трекере с версией vertx.

Короче, вам нужно настроить интеграцию IntelliJ Maven (surefire plugin), чтобы вести себя по-другому.

Сделайте это через: Preferences -> Build,Execution,Deployment -> Build Tools -> Maven -> Running Tests

Снимите флажок argLine

Это работает для меня в IntelliJ 14.1.6 с mvn 3.3.9

Ответ 3

Я смог исправить эту ошибку в Netbeans, изменив версию surefire-plugin на 2.10 и удалив

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

из конфигурации maven-surefire-plugin. Вместо этого я создал свойство argLine, которое автоматически выбирается с помощью 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>

Теперь я могу запускать и отлаживать отдельные файлы и методы тестирования. И Code Coverage работает как ожидалось.