Hello,

I have a project that uses Thorntail, and Arquillian for testing.
I have configured JaCoCo 0.8.5 to measure my code coverage but it does not 
detect the lines on which it has passed. Therefore, it returns a report 
with 0% coverage while the test function is passed.
The report that is generated is located under target\site\jacoco.
To reproduce the problem, I run the command mvn clean verify.
It may not be a bug but more of a configuration issue.

Can you help me please?

I can send you the code that isolates the problem and allows me to 
reproduce it systematically.
Below you will find part of the files.


*pom.xml*
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";
xmlns="http://maven.apache.org/POM/4.0.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
<modelVersion>4.0.0</modelVersion>

<groupId>fr.gfi.ecommerce</groupId>
<artifactId>referentiel</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>Gfi - ReferentielAPI</name>

<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<version.thorntail>2.6.0.Final</version.thorntail>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- Specify the JDK builder image used to build your application. -->
<fabric8.generator.from>registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift:latest</fabric8.generator.from>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>3.2</version>
<type>pom</type>
<scope>provided</scope>
</dependency> 
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
    
<!-- testing -->
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>arquillian</artifactId>
<scope>test</scope>
</dependency>
<dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>fluent-hc</artifactId>
      <version>4.5.2.redhat-2</version>
      <scope>test</scope>
    </dependency>
</dependencies>

<!-- Specify the repositories containing RHOAR artifacts -->
<repositories>
<repository>
<id>redhat-ga</id>
<name>Red Hat GA Repository</name>
<url>https://maven.repository.redhat.com/ga/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>redhat-ga</id>
<name>Red Hat GA Repository</name>
<url>https://maven.repository.redhat.com/ga/</url>
</pluginRepository>
</pluginRepositories>

<profiles>
<profile>
<id>thorntail-v2</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>io.thorntail</groupId>
<artifactId>thorntail-maven-plugin</artifactId>
<version>${version.thorntail}</version>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.5</version>
                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <!--  implementation is needed only for 
Maven 2  -->
                                <rule 
implementation="org.jacoco.maven.RuleConfiguration">
                                    <element>BUNDLE</element>
                                    <limits>
                                        <!--  implementation is needed only 
for Maven 2  -->
                                        <limit 
implementation="org.jacoco.report.check.Limit">
                                            <counter>COMPLEXITY</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.60</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>bom-all</artifactId>
<version>${version.thorntail}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>microprofile</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>openshift</id>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>4.3.1</version>
<executions>
<execution>
<goals>
<goal>resource</goal>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.0.0-M4</version>
</plugin>
</plugins>
</reporting>
</project>

*CivilitesEndpointTest.java*
package fr.gfi.ecommerce.referentiel.test.endpoints;

import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.fluent.Request;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.swarm.jaxrs.JAXRSArchive;

import fr.gfi.ecommerce.referentiel.endpoints.CivilitesEndpoint;


@RunWith(Arquillian.class)
public class CivilitesEndpointTest  {
private static Logger logger = Logger.getLogger(CivilitesEndpoint.class);
@Deployment
  public static JAXRSArchive myDeployment() {
File[] dependencies = Maven.resolver()
.loadPomFromFile("pom.xml")
.importRuntimeDependencies()
.resolve()
.withTransitivity()
.asFile();
return ShrinkWrap.create(JAXRSArchive.class, "referentiel.war")
.addAsResource("project-defaults.yml")
.addAsResource("META-INF/microprofile-config.properties")
.addAsLibraries(dependencies)
.addPackages(true, "fr.gfi.ecommerce");
  }
@Test
    @RunAsClient
    public void getAllCivilites() throws IOException { 

HttpResponse response = 
Request.Get("http://localhost:8084/referentiel/civilites?societe_only=false&particulier_only=false";)
.execute().returnResponse();
int status = response.getStatusLine().getStatusCode();
logger.infov("status = {0}", status);
assertTrue(200 == status);
String content = IOUtils.toString(response.getEntity().getContent(), 
StandardCharsets.UTF_8.name());
logger.infov("content = {0}", content);
assertTrue("{\"code\":\"M\",\"libelle\":\"Monsieur\"}".equals(content));
    }
}


*CivilitesEndpoint.java*
package fr.gfi.ecommerce.referentiel.endpoints;

import javax.enterprise.context.RequestScoped;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

import org.eclipse.microprofile.metrics.annotation.Metered;
import org.eclipse.microprofile.metrics.annotation.Timed;
import org.jboss.logging.Logger;

import fr.gfi.ecommerce.referentiel.entities.Civilite;

/**
 * API Civilité
 * @author Rémi Ollagnier
 *
 */
@Path("/civilites")
@RequestScoped
public class CivilitesEndpoint {
private static Logger logger = Logger.getLogger(CivilitesEndpoint.class);
/**
* Récupération des civilité en filtrant par type
* @param societeOnly true|false permet d'enlever ou non les civilités 
concernant les sociétés
* @param particulierOnly true|false permet d'enlever ou non les civilités 
concernant les particuliers
* @return Liste des civilités correspondantes
*/
@GET
@Produces("application/json")
@Path("/")
@Timed(description = "Timing de l'appel Civilites", name = 
"civilites-filtre-time", absolute = true)
@Metered(name = "getCivilites")
public Response doGet(@Context UriInfo uriInfo, @QueryParam("societe_only") 
boolean societeOnly, @QueryParam("particulier_only") boolean 
particulierOnly) {
logger.infov("doGet : societeOnly={0}, particulierOnly={1}", societeOnly, 
particulierOnly);
Civilite civilite = new Civilite();
civilite.setCode("M");
civilite.setLibelle("Monsieur");
return Response.ok().entity(civilite).build();
}
}



Best Regards,
Rémi Ollagnier

-- 
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/14ef728b-a76e-4bc7-be45-009da0f7dfbe%40googlegroups.com.

Reply via email to