# Generating Code Coverage Reports for System Tests with Quarkus

To measure System Test "black box" code coverage for a quarkus app, e.g. this sample code:



@Path("/hello")
public class GreetingResource {

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        return "Hello RESTEasy";
    }

    @POST
    @Consumes(MediaType.TEXT_PLAIN)
    public void sayHello(String message) {
        System.out.println(message);
    }    
}


add the following dependency to your pom.xml (use the latest jacoco version):


<dependency>
    <groupId>org.jacoco</groupId>
    <artifactId>org.jacoco.agent</artifactId>
    <classifier>runtime</classifier>
    <version>0.8.8</version>
    <scope>test</scope>
</dependency>



Now you build quarkus with the regular maven command: mvn clean package, then launch the app with:


java -javaagent:${HOME}/.m2/repository/org/jacoco/org.jacoco.agent/0.8.8/org.jacoco.agent-0.8.8-runtime.jar=destfile=./target/jacoco.exec,exclclassloader=*QuarkusClassLoader
                        -jar target/quarkus-app/quarkus-run.jar


All interactions with the app are recorded now. 


Perform: curl localhost:8080/hello and shutdown
quarkus.


    To generate a html report, perform: mvn org.jacoco:jacoco-maven-plugin:0.8.8:report


    The report is available from: target/site/jacoco/index.html. Because we only executed the
    @GET / hello() method, our code coverage amounts to 55%.


body, td {
  font-family:sans-serif;
  font-size:10pt;
}


.breadcrumb {
  border:#d6d3ce 1px solid;
  padding:2px 4px 2px 4px;
}

.breadcrumb .info {
  float:right;
}

.breadcrumb .info a {
  margin-left:8px;
}

.el_report {
  padding-left:18px;
  background-image:url(report.gif);
  background-position:left center;
  background-repeat:no-repeat;
}

.el_group {
  padding-left:18px;
  background-image:url(group.gif);
  background-position:left center;
  background-repeat:no-repeat;
}

.el_bundle {
  padding-left:18px;
  background-image:url(bundle.gif);
  background-position:left center;
  background-repeat:no-repeat;
}

.el_package {
  padding-left:18px;
  background-image:url(package.gif);
  background-position:left center;
  background-repeat:no-repeat;
}

.el_class {
  padding-left:18px;
  background-image:url(class.gif);
  background-position:left center;
  background-repeat:no-repeat;
}

.el_source {
  padding-left:18px;
  background-image:url(source.gif);
  background-position:left center;
  background-repeat:no-repeat;
}

.el_method {
  padding-left:18px;
  background-image:url(method.gif);
  background-position:left center;
  background-repeat:no-repeat;
}

.el_session {
  padding-left:18px;
  background-image:url(session.gif);
  background-position:left center;
  background-repeat:no-repeat;
}



table.coverage {
  empty-cells:show;
  border-collapse:collapse;
}

table.coverage thead {
  background-color:#e0e0e0;
}

table.coverage thead td {
  white-space:nowrap;
  padding:2px 14px 0px 6px;
  border-bottom:#b0b0b0 1px solid;
}

table.coverage thead td.bar {
  border-left:#cccccc 1px solid;
}

table.coverage thead td.ctr1 {
  text-align:right;
  border-left:#cccccc 1px solid;
}

table.coverage thead td.ctr2 {
  text-align:right;
  padding-left:2px;
}

table.coverage thead td.sortable {
  cursor:pointer;
  background-image:url(sort.gif);
  background-position:right center;
  background-repeat:no-repeat;
}

table.coverage thead td.up {
  background-image:url(up.gif);
}

table.coverage thead td.down {
  background-image:url(down.gif);
}

table.coverage tbody td {
  white-space:nowrap;
  padding:2px 6px 2px 6px;
  border-bottom:#d6d3ce 1px solid;
}

table.coverage tbody tr:hover {
  background: #f0f0d0 !important;
}

table.coverage tbody td.bar {
  border-left:#e8e8e8 1px solid;
}

table.coverage tbody td.ctr1 {
  text-align:right;
  padding-right:14px;
  border-left:#e8e8e8 1px solid;
}

table.coverage tbody td.ctr2 {
  text-align:right;
  padding-right:14px;
  padding-left:2px;
}

table.coverage tfoot td {
  white-space:nowrap;
  padding:2px 6px 2px 6px;
}

table.coverage tfoot td.bar {
  border-left:#e8e8e8 1px solid;
}

table.coverage tfoot td.ctr1 {
  text-align:right;
  padding-right:14px;
  border-left:#e8e8e8 1px solid;
}

table.coverage tfoot td.ctr2 {
  text-align:right;
  padding-right:14px;
  padding-left:2px;
}

.footer {
  margin-top:20px;
  border-top:#d6d3ce 1px solid;
  padding-top:2px;
  font-size:8pt;
  color:#a0a0a0;
}

.footer a {
  color:#a0a0a0;
}

.right {
  float:right;
}



    
        
            Element
            Missed Instructions
            Cov.
            Missed Branches
            Cov.
            Missed
            Cxty
            Missed
            Lines
            Missed
            Methods
        
    
    
        
            Total
            4 of 9
            55 %
            0 of 0
            n/a
            1
            3
            2
            4
            1
            3
        
    
    
        
            sayHello(String)
            
            
            0 %
            
            n/a
            1
            1
            2
            2
            1
            1
        
        
            GreetingResource()
            
            100 %
            
            n/a
            0
            1
            0
            1
            0
            1
        
        
            hello()
            
            100 %
            
            n/a
            0
            1
            0
            1
            0
            1
