0

Sonar と Jacoco が SO でレポートを正しく生成しないことについて多くの質問があることは知っていますが、どれも私の問題を解決するのに役立ちませんでした:

これが取引です:

Cobertura を使用してコード カバレッジを計算するプロジェクトがあり、それを変更することはできません。Sonar は、サーバー側に Cobertura を使用する必要があります。しかし、一方で、Selenium RC でテストされたこのクライアント (Java で smartGWT を使用する Web アプリケーションについて話している) があります (それが smartGWT をテストする唯一の方法であるため)。

これらのテストはデプロイされたアプリケーションで行われるため、Cobertura は Selenium テストのカバレッジを計算できません。Jacoco は Java エージェントとして起動されるため、それを計算できます。したがって、すべてが私のコンピューターで正常に機能しています。jacoco.exec が正常に生成されました。しかし、ソナーはそのファイルを読み取る方法を見つけられないようです。または、衝突しているのはcoberturaとjacocoだけかもしれません...

Jenkins が生成するエラーは次のとおりです。

[INFO] Surefire report directory: D:\JENKINS-SONAR\jobs\agepro PROTO\workspace\target\surefire-reports
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)
    at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:338)
Caused by: java.io.FileNotFoundException: D:\JENKINS-SONAR\jobs\agepro (Accès refusé)
    at java.io.FileOutputStream.openAppend(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:177)
    at org.jacoco.agent.rt_9w37ty.controller.LocalController.startup(LocalController.java:46)
    at org.jacoco.agent.rt_9w37ty.JacocoAgent.init(JacocoAgent.java:83)
    at org.jacoco.agent.rt_9w37ty.JacocoAgent.premain(JacocoAgent.java:165)
    ... 6 more
FATAL ERROR in native method: processing of -javaagent failed
Exception in thread "main" 

そして、これが確実なプラグインの私の構成です:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>-javaagent:${sonar.jacoco.jar}=destfile=${sonar.jacoco.reportPath}</argLine>
                    <excludes>
                        <exclude>**/Selenium*.java</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <id>surefire-integration-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <!-- <argLine>-javaagent:${sonar.jacoco.jar}=destfile=${sonar.jacoco.reportPath}</argLine> -->
                            <excludes>
                                <exclude>none</exclude>
                            </excludes>
                            <includes>
                                <include>**/Selenium*.java</include>
                            </includes>
                            <goal>selenium-test</goal>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

私が犯した可能性のある間違いがわかりますか?それとも、jacoco jar などに別のパスを設定する必要がありますか? とにかく助けてくれてありがとう。

4

1 に答える 1

1

名前reportPathは少し誤解を招くものです。

設定sonar.jacoco.reportPathは、ディレクトリではなくファイルを指す必要があります。

あなたはそれを次のように設定したようです: D:\JENKINS-SONAR\jobs\agepro: しかし、私はあなたが意味していると思いますD:\JENKINS-SONAR\jobs\agepro\jacoco.exec

さらに調べてみると、作業ディレクトリ「agepro PROTO」にスペースがあることが問題である可能性があることに気付きました。

これにより、Java エージェント構成の構文が壊れます。スペースを取り除くことができますか(うまくいくかどうかわかりませんdestfile='${sonar.jacoco.reportPath}'

于 2012-05-29T08:06:03.323 に答える