Skip to content

Commit f0d5f50

Browse files
authored
adjusted assert to make tests more specific and less likely to fail. (#703)
1 parent 05823b0 commit f0d5f50

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

test/smoke/testApps/CoreAndFilter/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/CoreAndFilterTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
import com.microsoft.applicationinsights.internal.schemav2.SeverityLevel;
1414
import com.microsoft.applicationinsights.telemetry.Duration;
1515

16+
1617
import org.junit.*;
1718

19+
import static org.hamcrest.Matchers.*;
1820
import static org.junit.Assert.*;
1921

2022
import java.util.List;
@@ -257,7 +259,8 @@ public void testRequestSlowWithResponseTime() {
257259
RequestData rd1 = getTelemetryDataForType(0, "RequestData");
258260
long actual = rd1.getDuration().getTotalMilliseconds();
259261
long expected = (new Duration(0, 0, 0, 20, 0).getTotalMilliseconds());
260-
assertTrue(actual >= expected);
262+
long tolerance = 2 * 1000; // 2 seconds
263+
assertThat(actual, both(greaterThanOrEqualTo(expected - tolerance)).and(lessThan(expected + tolerance)));
261264
}
262265

263266
@Ignore // See github issue #600. This should pass when that is fixed.

test/smoke/testApps/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ subprojects {
2828
smokeTestCompile project(':test:smoke:framework:testCore')
2929
smokeTestCompile project(':test:smoke:framework:utils')
3030
smokeTestCompile 'junit:junit:4.12'
31+
smokeTestCompile 'org.hamcrest:hamcrest-library:1.3'
3132

3233
testCompile project(':test:smoke:framework:testCore') // not necessary; vs code bug workaround
3334
testCompile project(':test:smoke:framework:utils')

0 commit comments

Comments
 (0)