我正在使用GWT maven项目,并希望找到代码覆盖率。 我收到报告的覆盖率为0%。
的pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.7.0</version>
<executions>
<execution>
<configuration>
<extraJvmArgs>-Xmx512m</extraJvmArgs>
</configuration>
<goals>
<goal>compile</goal>
<goal>generateAsync</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<argLine>${jacocoArgs}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jboss.errai</groupId>
<artifactId>jacoco-gwt-maven-plugin</artifactId>
<version>0.5.4.201202141554</version>
<configuration>
<snapshotDirectory>${project.build.directory}/test-classes</snapshotDirectory>
<propertyName>jacocoArgs</propertyName>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
GWTTestCase
public class GwtTestCovergeSample extends GWTTestCase {
public String getModuleName() {
return "com.test.sample.CovergeSampleJUnit";
}
public void testFieldVerifier() {
}
public void testGreetingService() {
GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
ServiceDefTarget target = (ServiceDefTarget) greetingService;
target.setServiceEntryPoint(GWT.getModuleBaseURL() + "CovergeSample/greet");
delayTestFinish(10000);
greetingService.greetServer("GWT User", new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
System.out.println("GwtTestCovergeSample.testGreetingService().new AsyncCallback() {...}.onFailure()");
fail("Request failure: " + caught.getMessage());
}
public void onSuccess(String result) {
assertTrue(result.startsWith("Hello, GWT User!"));
finishTest();
}
});
}
}
CoverageSampleJUnit.gwt.xml
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to="CovergeSample">
<inherits name='com.test.sample.CovergeSample' />
<servlet path="/CovergeSample/greet" class="com.test.sample.server.GreetingServiceImpl" />
</module>
在目标文件夹中,我可以看到正在使用正确的报告index.html文件创建站点文件夹。 当我打开index.html文件覆盖率报告时为0%。 有人请帮忙。