From 834276aa2bce38f38ddd0953cf58784996f0d22e Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 14 Apr 2015 17:15:35 +0100 Subject: [PATCH] Improve diagnostics in PublicMetricsAutoConfigurationTests multipleCacheManagers fails on the CI server but does not fail locally. This commit updates assertMetrics to include information about the actual metrics so it's clear why the expectation was not met. --- .../autoconfigure/PublicMetricsAutoConfigurationTests.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfigurationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfigurationTests.java index 2a6bbf95db03..fcd17aed2e00 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfigurationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfigurationTests.java @@ -56,9 +56,10 @@ import com.zaxxer.hikari.HikariDataSource; +import static org.hamcrest.Matchers.hasKey; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; @@ -236,7 +237,7 @@ private void assertMetrics(Collection> metrics, String... keys) { content.put(metric.getName(), metric.getValue()); } for (String key : keys) { - assertTrue("Key '" + key + "' was not found", content.containsKey(key)); + assertThat(content, hasKey(key)); } }