Search code examples
javaeclipse-plugincode-coveragemaven-pluginwildfly-swarm

Is there a plugin or tool which I can use to generate coverage from running application without testcases?


I have a Java based web application which have few ReST endpoints exposed. I want to check the code coverage in running VM. Is there any tool or plugin I can use for this purpose?

I tried looking into jacoco but It looks like it provides code coverage only if you have configured unit/integration tests.

Sometimes, it becomes very difficult to write testcases for all possible scenarios. So, is there a way I can get code coverage without test cases?

Thanks a ton in advance. :)


Solution

  • After doing more search on internet, I have found a very good link which fulfill my requirements: https://automationrhapsody.com/code-coverage-of-manual-or-automated-tests-with-jacoco/

    In short, follow below steps to generate code coverage report without testcases:

    1. Install Jacoco Eclipse plugin: EclEmma Java Code Coverage
    2. Download jacocoagent.jar and put it some location on your computer e.g. C:\JoCoCo\jacocoagent.jar
    3. Run your application with this VM arguments: - javaagent:C:\JaCoCo\jacocoagent.jar=output=tcpserver
    4. Import coverage reports:File -> Import -> Coverage Session -> select Agent address radio button but leave defaults -> enter some name and select code under test.