The tests sometimes failed because there is a timer scheduled to upload events and to store them in storage in case of failure.
The tests calls a dispose function which stops the timer but the already scheduled requests from the previous timer is going to happen anyway.
The test after calling dispose resets the mocks, therefore when the "save event to storage" function kicks in it crashes.
Implementation
The solution is simply to remove the reset of the mock because we don't need it since we are generating a new mock on each test.
This is not solving the issue of having pending operations after stoping the timer but does the job.
We've also done some cleanup of unnecessary "nullifications" and used the new later keyword.
Description
The tests sometimes failed because there is a timer scheduled to upload events and to store them in storage in case of failure. The tests calls a
dispose
function which stops the timer but the already scheduled requests from the previous timer is going to happen anyway. The test after calling dispose resets the mocks, therefore when the "save event to storage" function kicks in it crashes.Implementation
The solution is simply to remove the
reset
of the mock because we don't need it since we are generating a new mock on each test.This is not solving the issue of having pending operations after stoping the timer but does the job.
We've also done some cleanup of unnecessary "nullifications" and used the new
later
keyword.