fix tests with broken context mocks in android/player#774
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #774 +/- ##
=======================================
Coverage 85.77% 85.77%
=======================================
Files 504 504
Lines 22679 22679
Branches 2651 2651
=======================================
Hits 19454 19454
Misses 2896 2896
Partials 329 329 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| ] | ||
|
|
||
| # TODO: Update this to be updated automatically instead of maintaining a list manually | ||
| instrumented_test_classes = ['com.intuit.playerui.android.AndroidPlayerTest', 'com.intuit.playerui.android.AssetContextTest', 'com.intuit.playerui.android.AssetContextAndroidTest', 'com.intuit.playerui.android.renderer.NestedAssetTest', 'com.intuit.playerui.android.renderer.HydrationScopeTest', 'com.intuit.playerui.android.renderer.SimpleAssetTest', 'com.intuit.playerui.android.renderer.BrokenAssetTest', 'com.intuit.playerui.android.extensions.IntoKtTest', 'com.intuit.playerui.android.registry.RegistryPluginTest'] |
There was a problem hiding this comment.
do we need to do this in order to get all these tests picked up
There was a problem hiding this comment.
Yeah — there is logic here for automatically compiling this list, but it picks up every file. Ideally, we can expose that logic to let us filter out files (like not ending in Test) to build up the list here. We could also put the filter in the rule, but that's pretty opinionated.
There was a problem hiding this comment.
Yeah, if I don't add them manually, it picks up every .kt file as a test and any of the util / non-test files end up creating test targets that just throw errors.
| val player = AndroidPlayer() | ||
|
|
||
| assertEquals(5, player.plugins.size) | ||
| assertEquals(6, player.plugins.size) |
There was a problem hiding this comment.
when did the plugin numbers change? did we add some new default plugin?
There was a problem hiding this comment.
Looks like AsyncHydrationTrackerPlugin was added to buildDefaultPlugins of AndroidPlayer (code) about 5 months ago. I assume that's what made the difference here.
Issue: Some unit tests in
android/playerwere not running becauseMockKthrowing errors when it could not create a mock ofandroid.content.Context. The errors were being swallowed by something and the test runner would treat each of these files as having no tests rather than causing a failure.Fix:
androidTest.io.mockk:mockkto version1.12.5.JUnit4support was added in1.12.4(notes) so I updated to the latest non-breaking version I could find.AndroidPlayerTestchecked the number of plugins. The list is now size 6 instead of 5SimpleAssetTestwere failing with broken styles. Changed style used in these testsHydrationScopeTestwas failing the testtest hydration scope is cancelled on flow enddue to a race condition in the assertions. Added awaitForConditionto fix this.Change Type (required)
Indicate the type of change your pull request is:
patchminormajorN/ADoes your PR have any documentation updates?