bmuschko / gradle-clover-plugin

Gradle plugin for generating a code coverage report using Clover
Apache License 2.0
74 stars 49 forks source link

How to add integration tests analysis in Clover? #123

Open bettynicole opened 6 years ago

bettynicole commented 6 years ago

Hi,

I am a software developer trying to add our integration tests into Clover analysis. It’s a large, multi package distributed system. We have integrated Clover into Sonar and we use build.gradle. Originally our build.gradle contained the following lines:

sourceSets { main { jarName = "notification_service" // override the default jar name } test { jarName = "notification_service_unit_test" // override the default jar name } integrationTest { jarName = "notification_service_integration_test" // override the default jar name } }

clover { report { html = true xml = true excludes = ['/wing/model//*.java', '*/domain/dao/config/.java'] } }

and we used a sonar properties file something like:

sonar.language=java sonar.sources=glass/notification/src/src/main/java sonar.tests=glass/notification/src/src/test/java, glass/notification/src/src/integrationTest/java sonar.junit.reportsPath=glass/notification/install/common/test-results/junit sonar.dynamicAnalysis=reuseReports sonar.java.coveragePlugin=clover sonar.clover.reportPath=glass/notification/install/common/coverage-results/clover/clover.xml sonar.java.binaries=glass/notification/build sonar.java.libraries=/ms/dist/ossjava/PROJ/lombok/1.16.8/lib/.jar sonar.gate-profile.path=glass/notification/src/src/msde-train/sonar/sonar-gate-profile.xml sonar.exclusions=/wing/model//.java systemProp.sonar.host.url=http://localhost:9000

The output we obtained from clover (pie charts etc..) only covers unit tests. I can send you the output file separately if you tell me how. We’d like to get separate numbers for unit tests, integration tests and then their combination. I’ve tried to add the following lines to build.gradle, either one by one or in combinations:

clover { includeTasks = ['test', 'integrationTest']
testIncludes = ['/integrationTest/*.java', '*/test/.java'] additionalTestDirs = ['/integrationTest/'] additionalTestDirs = sourceSets.integrationTest.java.srcDirs …. }

None of those trials produced the desired result. Can you let me know if there’s a way to get separate numbers for unit tests, integration tests and their combination?

Thank you very much Betty bs89@caa.columbia.edu

Alex-Vol-SV commented 5 years ago

Sorry for not responding sooner Betty.

You cannot produce individual run reports in Clover. The clover database for a single project will contain the accumulated coverage numbers of all the instrumented executions for the project.

The integration test example in this plugin functional tests contains a working solution to get combined coverage results from multiple source sets. Your parameters in the clover closure may need to match the ones in this example: java-project-with-additional-tests

There is no need to specify includeTasks, the plugin will detect all tasks of type Test and will attach the clover compiler to each one.

As a suggestion you might consider to get individual coverage reports would be to split the integration tests into a separate project that runs against an instrumented JAR file from the first project. I have not tried that approach, it just occurred to me as I was writing this response to you.