[RUM-3845] Trying to get from Thread.sleep(SHORT_SLEEP_MS) in unit tests at DatadogEventListenerTest#2430
Conversation
e014a31 to
c33cee3
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #2430 +/- ##
========================================
Coverage 70.12% 70.12%
========================================
Files 769 769
Lines 28504 28505 +1
Branches 4774 4774
========================================
+ Hits 19986 19987 +1
+ Misses 7183 7173 -10
- Partials 1335 1345 +10
|
| assertThat(timing.downloadStart).isGreaterThanOrEqualTo(SHORT_SLEEP_NS) | ||
| assertThat(timing.downloadDuration).isGreaterThanOrEqualTo(SHORT_SLEEP_NS) |
There was a problem hiding this comment.
Note
Now that the timing value that is seen by the tested class are fixed and not flaky, we can use a strict equality assertion (.isEqualTo()) instead of a flaky inequality (.isGreaterThanOrEqualTo())
… instructions with sdkCore.time.deviceTimeNs replacements
07003a7 to
a422e7f
Compare
There was a problem hiding this comment.
nice change!
side note: while the ticket itself mentions only a single class, I guess its point is to do similar change in other classes as well, mainly in the RUM scopes related-classes and their tests; so the title of this PR can be a bit misleading.
Thanks, yep, planning to make similar changes in other places as well. |
What does this PR do?
In this PR we are trying to get rid of
Thread.sleepinstructions insideDatadogEventListenerTest.kt.To do so we use
sdkCore.time.deviceTimeNsat DatadogEventListener.kt instead ofSystem.nanoTime()method which let us mock time valuesMotivation
This approach makes this test independent from CI machine time and should increase test stability
Additional Notes
This is a WIP PR so changes could be non-final.
Review checklist (to be filled by reviewers)