Skip to content

Conversation

@alex-amenos
Copy link
Owner

@alex-amenos alex-amenos commented Nov 24, 2025

⚡️ Proposed Changes

  • Fix flaky tests

ℹ️ Additional Info

  • Add any additional useful context or info

🔗 Related Links

  • Add helpful links for this pull request

✅ Checklist

  • Unit Tests
  • Integration Tests
  • Compose Tests
  • Screenshot Tests
  • Updated string
  • Manually tested

📷 Screenshots

Copilot AI review requested due to automatic review settings November 24, 2025 20:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses flaky tests by removing unnecessary runCurrent() calls that occur before Turbine's test() function. When using Turbine to test Kotlin flows with runTest, runCurrent() is redundant because Turbine internally handles coroutine synchronization. The removal of these calls should improve test stability.

  • Removes runCurrent() call from one error handling test case
  • Aligns with the testing pattern used in PostsViewModelUnitTests.kt which successfully tests similar scenarios without runCurrent()
Comments suppressed due to low confidence (2)

feature/posts/src/test/kotlin/com/alxnophis/jetpack/posts/ui/viewmodel/PostsViewModelBehaviorSpec.kt:37

  • This runCurrent() call before turbine.test is unnecessary and can cause test flakiness, similar to the one removed at line 75-76. Turbine's test() function handles coroutine synchronization internally. The same test pattern in PostsViewModelUnitTests.kt (lines 46-50) works correctly without runCurrent(). This should be removed for consistency and to prevent potential flakiness.
                        runCurrent()

feature/posts/src/test/kotlin/com/alxnophis/jetpack/posts/ui/viewmodel/PostsViewModelBehaviorSpec.kt:100

  • This runCurrent() call before turbine.test is unnecessary and can cause test flakiness, similar to the one removed at line 75-76. Turbine's test() function handles coroutine synchronization internally. The same test pattern in PostsViewModelUnitTests.kt (lines 103-107) works correctly without runCurrent(). This should be removed for consistency and to prevent potential flakiness.
                        runCurrent()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@alex-amenos alex-amenos merged commit 6f54311 into main Nov 24, 2025
7 checks passed
@alex-amenos alex-amenos deleted the fix/tests branch November 24, 2025 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant