title: EclEmma JAVA Code coverage - Unable to coverage service layer of RESTful Webservice
body: <p>I am using EMMA eclipse plugin to generate code coverage reports.
  My application is a RESTFul webservice.
  Junits are written such that a client is created for the webservice and invoked with various inputs.</p>
  
  <p>However EMMA shows 0% coverage for the source folder. The test folder alone is covered.</p>
  
  <p>The application server(jetty server) is started using a main method.</p>
  
  <p>Report:</p>
  
  <pre><code>Element          Coverage    Covered Instructions    Total Instructions
  MyRestFulService  13.6%         900                     11846
  src                0.5%          49                     10412
  test              98%          1021                      1434
  </code></pre>
  
  <p>Junit Test method: </p>
  
  <pre><code>  @Test
    public final void testAddFlow() throws Exception {
          Client c = Client.create();
          WebResource webResource = c.resource(BASE_URI);
  
          // Sample files for Add
  
          String xhtmlDocument = null;
  
          Iterator iter = mapOfAddFiles.entrySet().iterator();
  
          while (iter.hasNext()) {
                Map.Entry pairs = (Map.Entry) iter.next();
  
                try {
                      document = helper.readFile(requestPath
                                  + pairs.getKey());
                } catch (Exception e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                }
                /* POST */
                MultiPart multiPart = new MultiPart();
                multiPart.bodyPart(....
                 ...........
                ClientResponse response = webResource.path("/add").type(
                            MEDIATYPE_MULTIPART_MIXED).post(ClientResponse.class,
                            multiPart);
  
                      assertEquals("TESTING ADD FOR &gt;&gt;&gt;&gt;&gt;&gt;&gt; " + pairs.getKey(),
                                  Status.OK, response.getClientResponseStatus());
  
  
  
                }
          }
    }
  </code></pre>
  
  <p>Invoked service method:</p>
  
  <pre><code>  @POST
    @Path("add")
    @Consumes("multipart/mixed")
    public Response add(MultiPart multiPart)
                throws Exception {
          Status status = null;
          List&lt;BodyPart&gt; bodyParts = null;
          bodyParts = multiPart.getBodyParts();
  
          status = //call to business layer
  
          return Response.ok(status).build();
    }
  </code></pre>