Skip to content
Snippets Groups Projects
Commit 42afd941 authored by René Schöne's avatar René Schöne
Browse files

use jacoco for coverage

parent 58ad4788
No related branches found
No related tags found
1 merge request!9Draft: Resolve "Add coverage"
Pipeline #9964 failed
......@@ -37,13 +37,26 @@ test:
needs:
- build
script:
- ./gradlew --console=plain --no-daemon allTests
- ./gradlew --console=plain --no-daemon allTests jacocoTestReport
artifacts:
when: always
paths:
- "ragconnect.tests/build/reports/jacoco/all-tests/jacoco*Report.xml"
reports:
junit: "ragconnect.tests/build/test-results/**/TEST-*.xml"
expire_in: 1 week
extractCoverage:
image: python:3.8-buster
stage: test
needs:
- test
script:
- pip install --user untangle
- cd ragconnect.tests/
- python extract-coverage-from-report.py
coverage: "/Covered (\\d{1,3}\\.\\d{2}%) of instructions for all projects\\./"
publish:
image: openjdk:11
stage: publish
......
......@@ -22,6 +22,7 @@ plugins {
id 'idea'
id 'com.github.ben-manes.versions' version '0.36.0'
id 'com.google.protobuf' version "0.8.14"
id 'jacoco'
}
apply plugin: 'jastadd'
......@@ -83,6 +84,17 @@ protobuf {
}
}
jacocoTestReport {
executionData tasks.withType(Test).findAll { it.state.executed }
getExecutionData().setFrom(fileTree(buildDir).include("/jacoco/*.exec"))
reports {
xml.enabled true
xml.destination(file("${jacoco.reportsDir}/all-tests/jacocoAllTestReport.xml"))
html.enabled false
}
}
task allTests(type: Test, dependsOn: testClasses) {
description = 'Run every test'
group = 'verification'
......
import os
import untangle
print('Current path: ' + os.path.abspath(os.curdir))
obj = untangle.parse('build/reports/jacoco/test/jacocoTestReport.xml')
instructions = [o for o in obj.report.counter if o['type'] == 'INSTRUCTION'][0]
missed, covered = int(instructions['missed']), int(instructions['covered'])
# print missed / (missed + covered)
print('Covered %.2f%% of instructions for all projects.' % (missed * 100.0 / (missed + covered)))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment