Skip to content

Resolve "Enabling Coverage through BDD Tests"

Andrei Danciuc requested to merge 2-enabling-coverage-through-bdd-tests into main

Closes #2 (closed)

Scope

Collect code coverage during runtime e2e test executions (BDD). This concrete example provide proof of concept how to make it.

How to reproduce

All is based on idea presented here https://ankeetmaini.dev/posts/getting-e2e-tests-coverage-for-java/

Just follow README.md from the BDD repo.

# if unittest fails on external data calls # -Dmaven.test.skip=true
make assembly-tcr-jars

Download jar agent and jar report.

# TODO: integrate this with maven if possible
make jacoco-1-download_wip

Start the server with the jacoco aggent

make jacoco-2-start-tcr-server_wip

Hit the server with test requests, e.g.

$ curl http://localhost:16100/actuator/health
{"status":"UP"}

# make run_all_bdd_dev

Generate html for people and xml report for Jenkins.

make jacoco-3-report_wip 

Evaluate the report

open submodule/trusted-content-resolver/service/coverage/index.html

Overall data

Screenshot_2024-01-02_at_00.18.56

Concrete Coverage in java class

Screenshot_2024-01-02_at_00.19.14

How to bring this feature in train K8s ?

> cat BDD/submodule/trusted-content-resolver/service/Dockerfile
FROM bellsoft/liberica-openjdk-alpine:21
COPY /target/trusted-content-resolver-service-*.jar trusted-content-resolver-service.jar
ENTRYPOINT ["java", "-jar","/trusted-content-resolver-service.jar"]

We can extend the existing dockerfile

> cat BDD/submodule/trusted-content-resolver/service/Dockerfile.withAgent
FROM tcr-server
COPY /target/jar/jacoco-*.jar .
ENTRYPOINT ["java", "-javaagent:jars/org.jacoco.agent-0.8.9-runtime.jar", "-jar","/trusted-content-resolver-service.jar"]

And testing with jenkins for CI only with tcr-server-with-agent, but for performance testing use just tcr-server.

We will need to have a common shared folder between: Jenkins-tcr-tspa to be able to access jacoco.exec for java and .coverage for python ... See the follow up ticket #3

Edited by Andrei Danciuc

Merge request reports

Loading