From d4b71c58dee249eed888b91db6802777f27cdea0 Mon Sep 17 00:00:00 2001 From: waschndolos Date: Tue, 9 Jan 2024 18:59:02 +0100 Subject: [PATCH] Fixing test --- .../plugins/prometheus/CodeCoverageCollectorTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/prometheus/CodeCoverageCollectorTest.java b/src/test/java/org/jenkinsci/plugins/prometheus/CodeCoverageCollectorTest.java index 14d762939..081e27f51 100644 --- a/src/test/java/org/jenkinsci/plugins/prometheus/CodeCoverageCollectorTest.java +++ b/src/test/java/org/jenkinsci/plugins/prometheus/CodeCoverageCollectorTest.java @@ -117,8 +117,10 @@ void shouldProduceMetricsWhenJobHasCoverageBuildAction() { configurationUtils.when(ConfigurationUtils::getNamespace).thenReturn("foo"); configurationUtils.when(ConfigurationUtils::getSubSystem).thenReturn("bar"); jenkinsStatic.when(Jenkins::get).thenReturn(jenkins); - configurationStatic.when(PrometheusConfiguration::get).thenReturn(config); + Job jobUnderTest = mock(Job.class); + when(jobUnderTest.getFullName()).thenReturn("some/job"); + Run lastBuild = mock(Run.class); when(lastBuild.isBuilding()).thenReturn(false); when(jobUnderTest.getLastBuild()).thenReturn(lastBuild); @@ -129,10 +131,12 @@ void shouldProduceMetricsWhenJobHasCoverageBuildAction() { when(config.getJobAttributeName()).thenReturn("jenkins_job"); when(config.isCollectCodeCoverage()).thenReturn(true); + configurationStatic.when(PrometheusConfiguration::get).thenReturn(config); + CodeCoverageCollector sut = new CodeCoverageCollector(); List collect = sut.collect(); - assertEquals(12, collect.size(), "12 metrics should have been collected"); + assertEquals(20, collect.size(), "20 metrics should have been collected"); } } } \ No newline at end of file