chetanmeh commented on a change in pull request #3249: #3243 - Use gradle 
scoverage to collect test coverage stats
URL: 
https://github.com/apache/incubator-openwhisk/pull/3249#discussion_r179813302
 
 

 ##########
 File path: tests/build.gradle
 ##########
 @@ -93,7 +102,63 @@ task createKeystore(dependsOn: deleteKeystore) {
 }
 
 afterEvaluate {
+    task testCoverageLean(type:Test) {
+        classpath = getScoverageClasspath(project)
+        exclude leanExcludes
+    }
+
+    task testCoverage(type:Test){
+        classpath = getScoverageClasspath(project)
+    }
     tasks.withType(Test) {
         dependsOn createKeystore
     }
 }
+
+/**
+ * Task to generate coverage xml report. Requires the
+ * tests to be executed prior to its invocation
+ */
+task reportCoverage(type: ScoverageReport){
+    dependsOn([
+            ':common:scala:reportScoverage',
+            ':core:controller:reportScoverage',
+            ':core:invoker:reportScoverage'
+    ])
+}
+
+/**
+ * Aggregates the scoverage xml reports from various modules into a
+ * single report
+ */
+task aggregateCoverage(type: JavaExec, dependsOn: reportCoverage) {
+    //Taken from ScoverageAggregate
+    main = 'org.scoverage.AggregateReportApp'
+    classpath = project.extensions.scoverage.pluginClasspath
+    args = [
+            project.rootProject.projectDir, //Use the root project path so as 
to "see" all source paths
+            new File(project.buildDir, 'scoverage-aggregate'),
+            false, //Clean scoverage report post process
+            true,  //coverageOutputCobertura
+            true,  //coverageOutputXML
+            true,  //coverageOutputHTML
+            false  //coverageDebug
+    ]
+}
+
+/**
+ * Prepares the classpath which refer to scoverage instrumented classes from
+ * dependent projects "before" the non instrumented classes
+ */
+def getScoverageClasspath(Project project){
 
 Review comment:
   Fixed the formatting now

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to