title: Code coverage for REST calls using jacoco
body: <p>I am using arquillian to test my REST endpoint. Here's a sample end point and test case that we are using.</p>
  
  <p><strong>REST ENDPOINT</strong></p>
  
  <pre><code>@Path("/v1/example")
  @Produces("application/json")
  @Consumes("application/json")
  public class HelloWorldResource {
  
      @EJB
      HelloWorldRemote helloWorldRemote;
  
      @GET
      @Path("/hello")
      public Response getSayHello(){
          String helloText = helloWorldRemote.sayHello();
          final Response  response = Response.ok(helloText).build();
          return response;
      }
  
      public String nonRESTSayHello(){
          return "SAY HELLO NONREST";
      }
  }
  </code></pre>
  
  <p><strong>TEST CASE:</strong></p>
  
  <pre><code>@RunWith(Arquillian.class)
  @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  public class HelloWorldResourceTest {
  
      @Test
      @OperateOnDeployment("REST")
      public void testGetSayHello() {
          System.out.println("testGETSAYHELLO!!!!!");
  
          Client client = ClientBuilder.newClient();
          Invocation.Builder builder = client.target(
                  "http://localhost:8080/CoverageTest/api/v1/example/hello")
                  .request(MediaType.APPLICATION_JSON_TYPE);
          javax.ws.rs.core.Response response = builder.get();
          assertEquals(200, response.getStatus());
  
      }
  
      /*
       * @Test 
       *  public void testNonRESTSayHello(){
       *      HelloWorldResource hwr=new HelloWorldResource(); 
       *      String str = hwr.nonRESTSayHello();
       *      assertEquals("SAY HELLO NONREST",str);
       * }
       */
  
  }
  </code></pre>
  
  <p>I am separating REST and NONREST elements into separate shrinkwrap archives and deploy it to server and testing. The problem is I am not getting jacoco coverage for REST endpoints. If I uncomment testNonRESTSayHello(), It will show coverage for the class - only for the method : nonRESTSayHello() although both methods are getting executed. The difference is the rest endpoint is acalled via Invocation.Builder from testcase. </p>
  
  <p>Any idea?</p>