2016-12-01 5 views
0

단위 테스트를 성공적으로 실행하려면 JVM에 대체 된 표준 클래스를 제공해야합니다. 따라서, 나는 maven-surefire-plugin에 대한 구성을 다음 사용 `-Xbootclasspath/p : my.jar` 옵션으로`jacoco-maven-plugin`을 실행하는 방법은 무엇입니까?

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <version>2.19.1</version> 
    <configuration> 
    <skipTests>${skipUTs}</skipTests> 
    <argLine>-Xbootclasspath/p:my.jar</argLine> 
    </configuration> 
</plugin> 

plugin/configuration/argLine

은 특별한 아무것도 추가하지 않습니다. 그러나 나는 어떻게 jacoco에게 동일한 것을 말할 수 있습니까? jacoco가 configuration/argLine :(이없는

내 pom.xml 파일에 다음과 같이 내가 메이븐 JaCoCo 플러그인을 구성한 :.

documentation of prepare-agent에 명시된 바와 같이
<plugin> 
    <groupId>org.jacoco</groupId> 
    <artifactId>jacoco-maven-plugin</artifactId> 
    <version>0.7.5.201505241946</version> 
    <configuration> 
    <skip>${skipUTs}</skip> 
    <!-- NO ONE (((((
    <argLine>-Xbootclasspath/p:my.jar</argLine> 
    --> 
    </configuration> 
    <executions> 
    <execution> 
     <id>default-prepare-agent</id> 
     <goals> 
     <goal>prepare-agent</goal> 
     </goals> 
    </execution> 
    <execution> 
     <id>default-report</id> 
     <phase>prepare-package</phase> 
     <goals> 
     <goal>report</goal> 
     </goals> 
    </execution> 
    <execution> 
     <id>default-check</id> 
     <goals> 
     <goal>check</goal> 
     </goals> 
     <configuration> 
     <rules> 
      <rule implementation="org.jacoco.maven.RuleConfiguration"> 
      <element>BUNDLE</element> 
      <limits> 
       <limit implementation="org.jacoco.report.check.Limit"> 
       <counter>COMPLEXITY</counter> 
       <value>COVEREDRATIO</value> 
       <minimum>1.0</minimum> 
       </limit> 
      </limits> 
      </rule> 
     </rules> 
     </configuration> 
    </execution> 
    </executions> 
</plugin> 
+0

[jacoco JVM args를 사용할 수없고 Maven에서 JVM args를 함께 사용할 수 없음] (http://stackoverflow.com/questions/23190107/cannot-use-jacoco-jvm-args-and-surefire-jvm-args) - 예를 들어 - 메이븐) – Godin

답변

1

- 단순히 사용되는 특성 argLine을 설정

<properties> 
    <argLine>-your -extra -arguments</argLine> 
</properties> 
<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <configuration> 
    <!-- no argLine here --> 
    </configuration> 
</plugin> 

또는 late property evaluation feature of maven-surefire-plugin 사용 :

maven-surefire-plugin에 의해, 당신은 추가 인수를 추가하는 두 가지 옵션이 있습니다
<properties> 
    <!-- empty to avoid JVM startup error "Could not find or load main class @{argLine}" in case when jacoco-maven-plugin not executed --> 
    <argLine></argLine> 
</properties> 
<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <configuration> 
    <argLine>@{argLine} -your -extra -arguments</argLine> 
    </configuration> 
</plugin>