You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, our flow testing methodology in the NowInAndroid project requires manually creating and canceling job objects to collect flows during tests. This approach can be error-prone and doesn't align with the latest best practices recommended in the Android developer documentation. (example in viewModel test )
Describe the solution
I propose updating our flow testing methodology to utilize backgroundScope for collecting flows. This solution offers several benefits:
Eliminates the need to manually create and cancel job objects.
Provides automatic cancellation of the coroutine before the end of the test.
Aligns with the latest best practices as documented by Android developers.
Implementation details:
• Replace current job creation and cancellation with backgroundScope.
• Update relevant test cases to use this new methodology.
• Ensure all tests pass with the new implementation.
i have already created a pull request implementing this change: #1585
Additional context
This change will simplify our test code, reduce the risk of forgetting to cancel job objects, and improve our alignment with current Android development best practices. It will make our tests more robust and easier to maintain in the long run.
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Describe the problem
Currently, our flow testing methodology in the NowInAndroid project requires manually creating and canceling job objects to collect flows during tests. This approach can be error-prone and doesn't align with the latest best practices recommended in the Android developer documentation. (example in viewModel test )
Describe the solution
I propose updating our flow testing methodology to utilize backgroundScope for collecting flows. This solution offers several benefits:
Implementation details:
• Replace current job creation and cancellation with backgroundScope.
• Update relevant test cases to use this new methodology.
• Ensure all tests pass with the new implementation.
References:
https://developer.android.com/kotlin/flow/test
https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-scope/background-scope.html
i have already created a pull request implementing this change: #1585
Additional context
This change will simplify our test code, reduce the risk of forgetting to cancel job objects, and improve our alignment with current Android development best practices. It will make our tests more robust and easier to maintain in the long run.
Code of Conduct
The text was updated successfully, but these errors were encountered: