diff --git a/README.asciidoc b/README.asciidoc index 6f5e24b..1afbf78 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -1,7 +1,8 @@ = JaCoCo-GWT Maven Plugin -This plugin makes it possible to collect and report on test coverage -from tests that extend GWTTestCase. +This is a fork of https://github.com/errai/jacoco-gwt-maven-plugin +The plugin is extended with the possibility to give the plain unit test classes precedence, in the case a method is tested by plain unit test and gwt testcase. You want to use this feature if the plain unit test has the better coverage than the gwt test case. +Check out the configuration `unitTestPrecedences` == Setup @@ -12,7 +13,10 @@ Add the following to the `` section of your pom.xml: org.jboss.errai jacoco-gwt-maven-plugin - 0.5.4.201202141554 + 0.6.5.201403032054 + + .*IHaveABetterPlainUnitTestCoverage\..*,.*MeToo\.* + jacoco-initialize diff --git a/pom.xml b/pom.xml index 799b67a..0da1e2d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,220 +1,220 @@ - - - - 4.0.0 - - org.jboss.errai - jacoco-gwt-maven-plugin - 0.5.4.201202141554 - maven-plugin - - JaCoCo :: GWT Maven Plugin - - The JaCoCo GWT Maven Plugin provides test coverage monitoring and reporting for GWTTestCase tests run under Maven. - - Based on the jacoco-maven-plugin project by Evgeny Mandrikov and Marc R. Hoffmann. - - Developed as part of the Errai framework. - - - - JBoss, by Red Hat - http://www.jboss.org/ - - - - Jonathan Fuerth - - - Christian Sadilek - - - - https://github.com/errai/jacoco-gwt-maven-plugin - - - jira - http://jira.jboss.org/jira/browse/ERRAI - - - - Eclipse Public License v1.0 - http://www.eclipse.org/legal/epl-v10.html - - - - - 2.1.0 - - - - - org.apache.maven - maven-plugin-api - ${project.prerequisites.maven} - - - org.apache.maven - maven-project - ${project.prerequisites.maven} - - - org.codehaus.plexus - plexus-utils - 1.5.6 - - - - org.jacoco - org.jacoco.agent - runtime - 0.5.4.201111111111 - - - org.jacoco - org.jacoco.core - 0.5.4.201111111111 - - - org.jacoco - org.jacoco.report - 0.5.4.201111111111 - - - - - src/main/java - src/main/resources - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.8 - - - - org.apache.maven.plugin-tools - maven-plugin-tools-javadoc - 2.8 - - - - - - org.apache.maven.plugins - maven-plugin-plugin - 2.6 - - - help-mojo - - helpmojo - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.3.1 - - - src/main/resources/META-INF/MANIFEST.MF - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - check-license-header - validate - - run - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.apache.maven.plugins - maven-antrun-plugin - [1.3,) - - run - - - - - - - - - - - - - - - - - - jboss-releases-repository - JBoss Releases Repository - https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/ - - - - jboss-snapshots-repository - JBoss Snapshots Repository - https://repository.jboss.org/nexus/content/repositories/snapshots/ - - - https://github.com/errai/jacoco-gwt-maven-plugin + + + + 4.0.0 + + org.jboss.errai + jacoco-gwt-maven-plugin + 0.8.6 + maven-plugin + + JaCoCo :: GWT Maven Plugin + + The JaCoCo GWT Maven Plugin provides test coverage monitoring and reporting for GWTTestCase tests run under Maven. + + Based on the jacoco-maven-plugin project by Evgeny Mandrikov and Marc R. Hoffmann. + + Developed as part of the Errai framework. + + + + JBoss, by Red Hat + http://www.jboss.org/ + + + + Jonathan Fuerth + + + Christian Sadilek + + + + https://github.com/errai/jacoco-gwt-maven-plugin + + + jira + http://jira.jboss.org/jira/browse/ERRAI + + + + Eclipse Public License v1.0 + http://www.eclipse.org/legal/epl-v10.html + + + + + 2.1.0 + + + + + org.apache.maven + maven-plugin-api + ${project.prerequisites.maven} + + + org.apache.maven + maven-project + ${project.prerequisites.maven} + + + org.codehaus.plexus + plexus-utils + 1.5.6 + + + + org.jacoco + org.jacoco.agent + runtime + 0.8.6 + + + org.jacoco + org.jacoco.core + 0.8.6 + + + org.jacoco + org.jacoco.report + 0.8.6 + + + + + src/main/java + src/main/resources + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + + + org.apache.maven.plugin-tools + maven-plugin-tools-javadoc + 2.8 + + + + + + org.apache.maven.plugins + maven-plugin-plugin + 2.6 + + + help-mojo + + helpmojo + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.3.1 + + + src/main/resources/META-INF/MANIFEST.MF + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + check-license-header + validate + + run + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-antrun-plugin + [1.3,) + + run + + + + + + + + + + + + + + + + + + jboss-releases-repository + JBoss Releases Repository + https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/ + + + + jboss-snapshots-repository + JBoss Snapshots Repository + https://repository.jboss.org/nexus/content/repositories/snapshots/ + + + https://github.com/errai/jacoco-gwt-maven-plugin \ No newline at end of file diff --git a/src/main/java/org/jboss/errai/gwtmaven/ReportMojo.java b/src/main/java/org/jboss/errai/gwtmaven/ReportMojo.java index 59f31c8..5887dbd 100644 --- a/src/main/java/org/jboss/errai/gwtmaven/ReportMojo.java +++ b/src/main/java/org/jboss/errai/gwtmaven/ReportMojo.java @@ -22,6 +22,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.regex.Pattern; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; @@ -88,6 +89,16 @@ public class ReportMojo extends AbstractJacocoMojo { */ private File snapshotDirectory; + /** + * The classes which are exercised from GWTTestCase and the unit tests, + * but shouldn't taken from the GWTTestCase recording to calculate the coverage. + * This is a comma separated list of regex patterns. + * Be aware that you have to match the compiled classes (eg. DoSomething.class, DoSomething$Innerclass.class). + * + * @parameter default-value="" + */ + private String unitTestPrecedences; + private SessionInfoStore sessionInfoStore; private ExecutionDataStore executionDataStore; @@ -286,14 +297,25 @@ protected List getFilesToAnalyze(File rootDir) throws IOException { // build two collections of relative pathnames List originalClasses = FileUtils.getFiles(rootDir, includes, excludes, false); - Set snapshotClases = getSnapshotRelativeFiles(); + Set snapshotClasses = getSnapshotRelativeFiles(); // now build one list of absolute pathnames, using items from the snapshot // list where they exist List filesToAnalyze = new ArrayList(originalClasses.size()); + + // create the regex for the classes which should taken from the originalClasses + Set unitTestPrecedencePatterns = new HashSet(); + if(StringUtils.isNotEmpty(unitTestPrecedences)) { + String[] unitTestPrecedences = this.unitTestPrecedences.split(","); + for(String unitTestPrecedence: unitTestPrecedences) { + getLog().info("added unitTestPrecedence pattern: " + unitTestPrecedence); + unitTestPrecedencePatterns.add(Pattern.compile(unitTestPrecedence)); + } + } + for (Object o : originalClasses) { File f = (File) o; - if (snapshotClases.contains(f)) { + if (snapshotContainClassAndPrecedenceIsNotOnUnitTest(snapshotClasses, f, unitTestPrecedencePatterns)) { filesToAnalyze.add(new File(snapshotDirectory, f.getPath())); getLog().debug("Using snapshot class for " + f); } @@ -305,6 +327,21 @@ protected List getFilesToAnalyze(File rootDir) throws IOException { return filesToAnalyze; } + private boolean snapshotContainClassAndPrecedenceIsNotOnUnitTest(Set snapshotClasses, File f, Set unitTestPrecedencePatterns) { + if(!unitTestPrecedencePatterns.isEmpty()){ + for(Pattern unitTestPrecedencePattern: unitTestPrecedencePatterns) { + if(unitTestPrecedencePattern.matcher(f.getName()).matches()) { + getLog().info("for class: " + f.getName() + " we give the unit test precedence [pattern: " + unitTestPrecedencePattern + "]"); + return false; + } + } + } + if(snapshotClasses.contains(f)) { + return true; + } + return false; + } + /** * Returns a set of File objects denoting the relative paths of all the files * under {@link #snapshotDirectory}. To turn an item {@code f} from the @@ -315,6 +352,9 @@ protected List getFilesToAnalyze(File rootDir) throws IOException { */ @SuppressWarnings("unchecked") private HashSet getSnapshotRelativeFiles() throws IOException { + if(!snapshotDirectory.exists()) { + return new HashSet(); + } return new HashSet(FileUtils.getFiles(snapshotDirectory, "**", "", false)); }