-
Bug
-
Resolution: Fixed
-
Minor
-
None
I am writing unit tests for my Jenkins pipelines, involving some custom logic for retrieving/handling the coverage results. For this, I rely on the coverage-model module:
dependencies { // ... implementation 'edu.hm.hafner:coverage-model:0.46.0' // ... }
Using
import edu.hm.hafner.coverage.Coverage.CoverageBuilder
now to implement something similar to the original pipeline with
private Optional<Value> convertToCoverage(final Fraction fraction, final Metric metric) { return Optional.ofNullable( new CoverageBuilder().withMetric(metric) .withCovered(fraction.getNumerator()) .withTotal(fraction.getDenominator()) .build() ) }
I am observing issues about edu.hm.hafner.util.Ensure not being available. The Gradle dependency tree does not report a suitable dependency as well.
Trying to find a standalone package for this turned out to not be easy: I could either use codingstyle-pom which does not seem to make much sense for a standalone use case or retrieve my own copy from either https://github.com/uhafner/codingstyle/blob/main/src/main/java/edu/hm/hafner/util/Ensure.java or https://github.com/uhafner/config/blob/master/src/main/java/edu/hm/hafner/util/Ensure.java, which does not feel correct either and introduces further dependencies which do not seem to be necessary.
At the moment, I am using a local copy of Ensure.java without external dependencies, but this does not feel correct. In my opinion, edu.hm.hafner.util should be distributed as a regular package for further re-use to allow clean library usage.