@@ -62,7 +62,9 @@ void shouldCaptureTimeGauge() {
6262 TimeGauge .builder ("test-time-gauge" , "" , MILLISECONDS , obj -> 11.0 ).register (registry );
6363
6464 // then
65- await ().until (() -> getLastMeasurement ("test-time-gauge" ) != null );
65+ await ()
66+ .atMost (Duration .ofSeconds (20 ))
67+ .until (() -> getLastMeasurement ("test-time-gauge" ) != null );
6668
6769 AgentTestingMicrometerDelegate .Measurement measurement = getLastMeasurement ("test-time-gauge" );
6870 assertThat (measurement .value ).isEqualTo (11 );
@@ -81,7 +83,7 @@ void shouldCaptureGauge() {
8183 Gauge .builder ("test-gauge" , () -> 22.0 ).register (registry );
8284
8385 // then
84- await ().until (() -> getLastMeasurement ("test-gauge" ) != null );
86+ await ().atMost ( Duration . ofSeconds ( 20 )). until (() -> getLastMeasurement ("test-gauge" ) != null );
8587
8688 AgentTestingMicrometerDelegate .Measurement measurement = getLastMeasurement ("test-gauge" );
8789 assertThat (measurement .value ).isEqualTo (22 );
@@ -102,7 +104,7 @@ void shouldCaptureCounter() {
102104 counter .increment (3.3 );
103105
104106 // then
105- await ().until (() -> getLastMeasurement ("test-counter" ) != null );
107+ await ().atMost ( Duration . ofSeconds ( 20 )). until (() -> getLastMeasurement ("test-counter" ) != null );
106108
107109 AgentTestingMicrometerDelegate .Measurement measurement = getLastMeasurement ("test-counter" );
108110 assertThat (measurement .value ).isEqualTo (3.3 );
@@ -123,7 +125,7 @@ void shouldCaptureTimer() {
123125 timer .record (Duration .ofMillis (55 ));
124126
125127 // then
126- await ().until (() -> getLastMeasurement ("test-timer" ) != null );
128+ await ().atMost ( Duration . ofSeconds ( 20 )). until (() -> getLastMeasurement ("test-timer" ) != null );
127129
128130 AgentTestingMicrometerDelegate .Measurement measurement = getLastMeasurement ("test-timer" );
129131 assertThat (measurement .value ).isEqualTo (99 );
@@ -146,7 +148,7 @@ void shouldCaptureDistributionSummary() {
146148 distributionSummary .record (5.5 );
147149
148150 // then
149- await ().until (() -> getLastMeasurement ("test-summary" ) != null );
151+ await ().atMost ( Duration . ofSeconds ( 20 )). until (() -> getLastMeasurement ("test-summary" ) != null );
150152
151153 AgentTestingMicrometerDelegate .Measurement measurement = getLastMeasurement ("test-summary" );
152154 assertThat (measurement .value ).isEqualTo (9.9 );
@@ -190,6 +192,7 @@ void shouldCaptureLongTaskTimer() {
190192
191193 // then
192194 await ()
195+ .atMost (Duration .ofSeconds (20 ))
193196 .untilAsserted (
194197 () -> {
195198 AgentTestingMicrometerDelegate .Measurement activeMeasurement =
@@ -207,6 +210,7 @@ void shouldCaptureLongTaskTimer() {
207210 assertThat (activeMeasurement .namespace ).isNull ();
208211
209212 await ()
213+ .atMost (Duration .ofSeconds (20 ))
210214 .untilAsserted (
211215 () -> {
212216 AgentTestingMicrometerDelegate .Measurement durationMeasurement =
@@ -233,7 +237,9 @@ void shouldCaptureFunctionCounter() {
233237 FunctionCounter .builder ("test-function-counter" , "" , obj -> 6.6 ).register (registry );
234238
235239 // then
236- await ().until (() -> getLastMeasurement ("test-function-counter" ) != null );
240+ await ()
241+ .atMost (Duration .ofSeconds (20 ))
242+ .until (() -> getLastMeasurement ("test-function-counter" ) != null );
237243
238244 AgentTestingMicrometerDelegate .Measurement measurements =
239245 getLastMeasurement ("test-function-counter" );
@@ -254,7 +260,9 @@ void shouldCaptureFunctionTimer() {
254260 .register (registry );
255261
256262 // then
257- await ().until (() -> getLastMeasurement ("test-function-timer" ) != null );
263+ await ()
264+ .atMost (Duration .ofSeconds (20 ))
265+ .until (() -> getLastMeasurement ("test-function-timer" ) != null );
258266
259267 AgentTestingMicrometerDelegate .Measurement measurement =
260268 getLastMeasurement ("test-function-timer" );
0 commit comments