diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml index e614dea160..2540ce063b 100644 --- a/.github/workflows/ci-maven.yaml +++ b/.github/workflows/ci-maven.yaml @@ -22,9 +22,12 @@ jobs: - run: java -version - name: Unit Tests run: | - mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \ - -Dfmt.skip + mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \ + -Dfmt.skip -DenableTestCoverage - run: bazelisk version + - name: Install maven modules + run: | + mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip - name: Integration Tests run: | bazelisk --batch test //test/integration/... @@ -71,7 +74,6 @@ jobs: set -x export JAVA_HOME=$JAVA11_HOME export PATH=${JAVA_HOME}/bin:$PATH - # Why not compile? It's because the process needs to package jar so # that gapic-generator-java module can use testlib modules of gax. mvn verify --batch-mode --no-transfer-progress -Dcheckstyle.skip \ diff --git a/coverage-report/README.md b/coverage-report/README.md new file mode 100644 index 0000000000..9326c426a2 --- /dev/null +++ b/coverage-report/README.md @@ -0,0 +1,23 @@ +## Coverage Report + +This module gathers aggregated jacoco test coverage metrics across the `gax-java` and `showcase` modules. The purpose of +the metrics is to provide insights into how much of GAX code is being exercised by showcase and GAX tests and where +(unit tests versus integration tests). They will also provide information on any change in coverage observed +as showcase tests continue to be added to the repository. + +### Unit Test Coverage +In order to view aggregate unit test coverage of GAX in both `gax-java` and `showcase`: + +1. At the root of the repository, run `mvn clean test -DenableTestCoverage`. +2. The metrics can be found at `gapic-generator-java/coverage-report/target/site/jacoco-aggregate/index.html` + +![Screenshot 2023-03-03 at 6 32 50 PM](https://user-images.githubusercontent.com/66699525/222854612-787b4dde-f9a3-469a-8227-8f46dc0a4a20.png) + +### Integration Test Coverage + +In order to view aggregate integration test coverage of GAX in both `gax-java` and `showcase`: + +1. At the root of the repository, run `mvn clean verify -DskipUnitTests -DenableTestCoverage -Penable-integration-tests`. +2. The metrics can be found at `gapic-generator-java/coverage-report/target/site/jacoco-aggregate/index.html` + +![Screenshot 2023-03-03 at 6 36 26 PM](https://user-images.githubusercontent.com/66699525/222854973-f8a96f01-abc1-4e6b-9ab8-99b5e50dec6a.png) \ No newline at end of file diff --git a/coverage-report/pom.xml b/coverage-report/pom.xml new file mode 100644 index 0000000000..7851a2aa7f --- /dev/null +++ b/coverage-report/pom.xml @@ -0,0 +1,81 @@ + + + 4.0.0 + com.google.cloud + coverage-report + pom + 0.0.1-SNAPSHOT + Jacoco Aggregrate Test Coverage Report + + + UTF-8 + true + true + true + 8 + true + + ${project.basedir}/coverage-report/target/site/ + jacoco-aggregate/jacoco.xml + + + + + + com.google.cloud + gapic-showcase + 0.0.1-SNAPSHOT + test + + + com.google.api + gax + 2.23.3-SNAPSHOT + + + com.google.api + gax-grpc + 2.23.3-SNAPSHOT + + + com.google.api + gax-httpjson + 0.108.3-SNAPSHOT + + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.8 + + + unit-tests-report-aggregate + + report-aggregate + + test + + + integration-tests-report-aggregate + + report-aggregate + + integration-test + + + + + com.coveo + fmt-maven-plugin + 2.9 + + + + + + diff --git a/gapic-generator-java-pom-parent/pom.xml b/gapic-generator-java-pom-parent/pom.xml index 91addcbc56..1c7a9ce31d 100644 --- a/gapic-generator-java-pom-parent/pom.xml +++ b/gapic-generator-java-pom-parent/pom.xml @@ -95,8 +95,89 @@ - + + test-coverage + + + enableTestCoverage + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M8 + + + + **/*SmokeTest.java + **/IT*.java + + sponge_log + ${surefire.jacoco.args} + ${skipUnitTests} + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.0.0-M8 + + + + integration-test + verify + + + + + 3600 + sponge_log + + **/IT*.java + **/*SmokeTest.java + + ${failsafe.jacoco.args} + + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.8 + + + unit-test-execution + + prepare-agent + + + surefire.jacoco.args + + + + integration-test-execution + pre-integration-test + + prepare-agent + + + failsafe.jacoco.args + + + + + + + + + google-maven-central-copy diff --git a/pom.xml b/pom.xml index 300f0d658b..8cf21209d2 100644 --- a/pom.xml +++ b/pom.xml @@ -77,6 +77,19 @@ + + + activate-test-coverage + + + enableTestCoverage + + + + showcase + coverage-report + + diff --git a/showcase/gapic-showcase/pom.xml b/showcase/gapic-showcase/pom.xml index 8c3de921fd..c9ced7d6b5 100644 --- a/showcase/gapic-showcase/pom.xml +++ b/showcase/gapic-showcase/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.google.cloud gapic-showcase - 0.0.1-SHAPSHOT + 0.0.1-SNAPSHOT jar GAPIC Showcase Client @@ -171,18 +171,21 @@ com.google.api gax + test-jar testlib test com.google.api gax-grpc + test-jar testlib test com.google.api gax-httpjson + test-jar testlib test