vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
622 stars 167 forks source link

Investigate code coverage tool #7948

Open bogdanudrescu opened 4 years ago

bogdanudrescu commented 4 years ago

Investigate code coverage tools that could be used to report how unit tests cover the code by highlighting code not covered by the unit tests.

Eg. https://www.eclemma.org/, jacoco maven plugin.

Acceptance criteria:

knoobie commented 4 years ago

This won't fulfill all your criteria, but it could be a starting point. This is my default go to in all my projects:

A good place for this configuration could be your vaadin-parent.

build-parent.pom:

  <profiles>
    <profile>
      <id>jenkins</id>
      <activation>
        <!-- Profile that is automatically activated when run in Jenkins because Jenkins creates a env.BUILD_NUMBER-->
        <property>
          <name>env.BUILD_NUMBER</name>
        </property>
      </activation>
      <build>
        <plugins>
          <!-- Plugin that creates a coverage report -->
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${jacoco.version}</version>
            <configuration>
              <destFile>${maven.multiModuleProjectDirectory}/.build/jacoco.exec</destFile>
              <append>true</append>
            </configuration>
            <executions>
              <execution>
                <id>agent</id>
                <goals>
                  <goal>prepare-agent</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

Jenkins pipeline file:

        stage('JaCoCo') {
            steps {
                jacoco(
                        changeBuildStatus: true,
                        classPattern: '**/classes,**/**/classes',
                        execPattern: '.build/jacoco.exec',
                        sourcePattern: '**/src/main/java,**/**/src/main/java'
                )
            }
        }