I am working with Groovy 2.5.9, Gradle 6 and Spock Test Framework. 

As per Design Groovy closures are generating Closure classes and some 
internal getter methods.  Is it posssible to eliminate the generated 
methods in these Closure classes ? 

Some of Groovy generated methods are excluded as per Wiki page 
https://github.com/jacoco/jacoco/wiki/FilteringOptions#groovy

Does Closures covered in these filtering options ? If not, will it be 
possible enhance these in Jacoco ?

Build.gradle 
============

plugins {

      id 'groovy'

    id 'jacoco'

}


repositories {

    jcenter()

}


dependencies {

 

       implementation 'org.codehaus.groovy:groovy:2.5.9'

      implementation 'org.codehaus.groovy:groovy-json:2.5.9'

    // Use JUnit test framework

   testImplementation 'junit:junit:4.12'

        testImplementation 'org.spockframework:spock-core:1.3-groovy-2.5'

      

}


jacocoTestReport {

     

       reports {

              xml.enabled *false*

              csv.enabled *false*

              html.destination file("${reportsDir}/jacoco")

  }

}

============= Main class ==== 

*import* java.util.concurrent.CompletableFuture


*public* *class* GroovyClosureMain {

       

       *def* String method1(*def* name) {

         

               *def* name1 = 'Hello ' + name 

            *def* text =  ' - Closure Test'

           

              CompletableFuture<Object> future = callAsync(name1, text)

              

                *return* future.get()

    }

      

        *def* CompletableFuture<Object> callAsync(arg1, arg2) {

          *return* CompletableFuture.*supplyAsync*({ *return* arg1 + ' ' + 
arg2  })

            

        }

       

}

=============

Test Class

*import* spock.lang.Specification


*class* GroovyClosureTest *extends* Specification{


        *def* "Test Closure1" () {

               setup:

         GroovyClosureMain mainCls =  *new* GroovyClosureMain()

           String name = "Name"

           

               when:

          String response = mainCls.method1(name)


                then:

          *assert* response != *null*

}

      

         

}




-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/bffb5964-b2bb-4aa8-8509-a49a39c95f8f%40googlegroups.com.

Reply via email to