0

I have a multi module application "Project A". This application is hosted in clustered app nodes using tomcat as web server. We are using Spring, Web Services as primary among many other technologies to build this.

For doing the API Automation i have another project "Project B" which test all the public API of "Project A" using rest-assured.

Both the "Project A" and "Project B" are distinctly different and hosted in different GIT location. We do the build and test using Jenkins.

Now my requirement is to get code coverage of "Project A" using "Project B".

What I have Done till now:

A. I have installed jacoco-agent.jar in each of my app node and put the "JACOCO-ARGS" in the web server start up script.

JACOCO_OPTS="-javaagent:/opt/itop/jacoco-agent.jar=destfile=/opt/itop/jacoco-
it.exec,output=file,append=true,jmx=true"

JAVA_OPTS="${JAVA_OPTS} ${JACOCO_OPTS}"

B. We usually keep one node on only while looking for code coverage.

What I am getting now:

I am getting the jacoco-it.exec file generated but with very less coverage. With all the API passing i am getting only 3% coverage at max. Where as by doing manual testing we are getting more than 50%.

What I am looking for:

  1. Is there any other step which I am missing here?
  2. How to get max code coverage for this set up?
  3. What is the standard I need to follow while looking for code coverage?
0
  1. Check if your API tests with rest-assured operate with all the possible parameters (not just end-points) that could run your API in all possible ways
  2. Do not ignore negative tests. In my experience we just missed 50% of coverage because of we didn't bring the system into exceptional states which prevented the code to run into corresponding exception handling areas
  • Each of the API is covered with positive and negative test cases. Still getting this 3% only – Prabhudatta Choudhury Oct 26 '18 at 10:25
  • You should have the report that would not only show the percentage but also uncovered code sections. You should analyze them to understand what should be amended in your tests. – Alexey R. Oct 26 '18 at 10:34
  • that report says some of the code got covered. But when we perform manual task those uncovered part also covering. The problem here is through API we are doing the same operation which manual team is doing. My question is how jacoco is differentiating it? is UI touch is mandatory to have a code coverage (I dont think so though)? How the connection should be set for jacoco-agent in app server so that it will capture each and every action perform on the application code? – Prabhudatta Choudhury Nov 1 '18 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.