2

I have a spring-boot project with existing unit tests and Karate integration tests that interact with my application during my maven build cycles and I want to have a generated report that tells me which REST API endpoints are interacted with and are covered by my existing tests.

I would like to generate a report similar to swagger-coverage report as depicted in this image: enter image description here

  • I tried to configure Karate library to generate such reports but it is very much dependent on heavy customization and just adds information to existing scenario's and would add much wait on maintainability of the application.
  • I considered using Swagger-Coverage library from github https://github.com/viclovsky/swagger-coverage but it does not seem to support Karate configuration and needs code based approach to insert itself and make the reports possible

2 Answers 2

1

You can maybe use Keploy as an alternative solution for generating API test coverage reports. It can be used easily with existing testSuite that you have. Best part is that alongside visuals report you also do get them in yml similar to below -

file_coverage:
    com/example/demo/SamplesJavaApplication: 100.00%
    com/example/demo/controller/EmployeeController: 68.85%
    com/example/demo/exception/ErrorDetails: 63.64%
    com/example/demo/exception/GlobalExceptionHandler: 53.85%
    com/example/demo/exception/ResourceNotFoundException: 100.00%
    com/example/demo/model/Employee: 89.47%
total_coverage: 70.49%

REST API endpoints are interacted with and are covered by my existing tests

Since it's yml, i have created testSuites for each functionality and pretty much just check for the lines covered by testcases (keploy & karate). Both a bit does overlap sometimes, and in those scenarios as of i just go with more with the one that covers more line in codebase.

Sign up to request clarification or add additional context in comments.

Comments

0

You can do this via Hooks, and here is a blog post someone wrote about it: Link.

Information about the RuntimeHook can be found here: https://stackoverflow.com/a/60944060/143475

Yes ideally it should be part of Karate, maybe it will happen in the future.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.