Consider adding a way to de-init or reset Glean to the public test API
Categories
(Data Platform and Tools :: Glean: SDK, enhancement, P1)
Tracking
(Not tracked)
People
(Reporter: travis_, Assigned: Dexter)
References
Details
(Whiteboard: [telemetry:glean-rs:m7])
Attachments
(2 files)
This has been discussed a lot, but I think that there is still a real need for this. Some of the latest discussion can be found here in a PR I was working on that ran into the problem head-on.
The TL;DR is that Glean, being implemented the way that it is, can persist state between tests in the same class, as well as between tests in different test classes. I'm sure that this is probably causing us trouble with intermittent test failures, as well as sometimes making the order that tests are ran in significant (which in itself is an issue as we have no good way to control the order in which the tests are ran).
| Assignee | ||
Updated•6 years ago
|
| Assignee | ||
Comment 1•6 years ago
|
||
One possible way to tackle this could be to define a custom JUnit rule, exported by the Glean SDK, that takes care of resetting the Glean state between tests, while keeping implementation details sealed within the Glean SDK.
Comment 3•6 years ago
|
||
A related issue is that failure to call Glean.initialize results in obscure errors in unit tests. Having a standard rule to apply to Glean-using tests would be a good way to plug that hole.
lateinit property applicationContext has not been initialized
at mozilla.components.service.glean.storages.GenericStorageEngine.getApplicationContext(GenericStorageEngine.kt:40)
at mozilla.components.service.glean.storages.GenericStorageEngine.deserializeLifetime(GenericStorageEngine.kt:105)
at mozilla.components.service.glean.storages.GenericStorageEngine$pingLifetimeStorage$2.invoke(GenericStorageEngine.kt:50)
at mozilla.components.service.glean.storages.GenericStorageEngine$pingLifetimeStorage$2.invoke(GenericStorageEngine.kt:39)
| Assignee | ||
Updated•6 years ago
|
| Assignee | ||
Updated•6 years ago
|
| Assignee | ||
Comment 4•6 years ago
|
||
| Assignee | ||
Comment 6•6 years ago
|
||
| Assignee | ||
Updated•6 years ago
|
Description
•