Uploaded image for project: 'Thorntail'
  1. Thorntail
  2. THORN-1309

The Jacoco reports 0% code coverage.

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Out of Date
    • Affects Version/s: 2017.4.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Story Points:
      5
    • Steps to Reproduce:
      Hide

      The minimal project for reproducing is published via GitHub at https://github.com/charleech/swarm-arq-jacoco

      Just simply execute "mvn clean install site"

      The target/site/jacoco-it/index.html shows that it is 0% coverage on integration testing.

      On the other hand the target/site/jacoco/index.html shows that it is 100% coverage for unit testing.

      To ensure that the jacoco creates the exec separately for unit testing and integration, there are separated files at target/coverage-reports/jacoco-unit.exec and target/coverage-reports/jacoco-it.exec

      Show
      The minimal project for reproducing is published via GitHub at https://github.com/charleech/swarm-arq-jacoco Just simply execute "mvn clean install site" The target/site/jacoco-it/index.html shows that it is 0% coverage on integration testing. On the other hand the target/site/jacoco/index.html shows that it is 100% coverage for unit testing. To ensure that the jacoco creates the exec separately for unit testing and integration, there are separated files at target/coverage-reports/jacoco-unit.exec and target/coverage-reports/jacoco-it.exec

      Description

      I'm using "wildfly-swarm: 2017.4.0" and have tried to create the integration test via the "wildfly-swarm-arquillian: 2017.4.0". It works properly the integration test is executed successfully. Anyhow when I create the "maven site", the jacoco reports 0% code coverage on integration test. On the other hand, the jacoco reports 100% code coverage on unit testing. The jacoco exec is created separately for unit testing and integration testing,

      By overview the target class is a simple CDI bean as the following: -

      @ApplicationScoped
      public class MyCdi implements Serializable {
      
          private static final long serialVersionUID = 1L;
      
          public String say(final String name) {
              return "Hello " + name;
          }
      
      }
      

      The unit test is

      public class SwarmArqJacocoTester {
      
      
          private final MyCdi myCdi = new MyCdi();
      
          @Test
          public void whenEnsureCdi() {
              BDDAssertions.then(this.myCdi).
                            as("The CDI injected bean must not be null.").
                            isNotNull();
      
              BDDAssertions.then(this.myCdi.say("Charlee")).
                            as("The said message must be valid.").
                            isEqualTo("Hello Charlee");
          }
      }
      

      The integration is

      @RunWith(Arquillian.class)
      public class SwarmArqJacocoIntgrtnTester {
      
          @Deployment(name = "swarm-arq-jacoco")
          public static WebArchive createDeployment() {
              WebArchive        web       = null;
              try {
      
                  web       = ShrinkWrap.create(WebArchive.class,
                                                "myweb.war").
                                         addPackages(true, "com.sample").
                                         addPackages(true, "test.com.sample").
                                         addPackages(true, "it.test.com.sample").
                                         addAsWebInfResource(
                                              new File("src/test/resources/META-INF/beans.xml"),
                                              "bean.xml");
                  web.addAsLibraries(ArtifactLookup.get().
                                                artifact("org.assertj:assertj-core"));
      
                  return web;
              } catch (final Exception e) {
                  throw new IllegalStateException("Cannot create archive.",
                                                  e);
              }
          }
      
          @Inject
          private MyCdi myCdi;
      
          @Test
          @InSequence(1)
          public void whenEnsureCdi() {
              BDDAssertions.then(this.myCdi).
                            as("The CDI injected bean must not be null.").
                            isNotNull();
      
              BDDAssertions.then(this.myCdi.say("Charlee")).
                            as("The said message must be valid.").
                            isEqualTo("Hello Charlee");
          }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                charlee_ch Charlee Chitsuk
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: