Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates test library dependencies and refactors test code to align with Turbine 1.0.0 and Coroutines 1.7.3 APIs. The changes migrate from nested test {} blocks to a cleaner = test syntax and replace deprecated Turbine methods with their modern equivalents.
- Updated Coroutines from 1.6.4 to 1.7.3 and Turbine from 0.12.0 to 1.0.0
- Refactored all test functions to use
= testsyntax instead of nestedtest {}blocks - Replaced
awaitCancellation()withcancelAndIgnoreRemainingEvents()and addedadvanceUntilIdle()calls after async operations
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| gradle/libs.versions.toml | Updated test library versions for coroutines and turbine |
| LifecycleViewModelTest.kt | Refactored test syntax to use = test pattern and added advanceUntilIdle() calls |
| SettingsViewModelTest.kt | Migrated to new test patterns with flow testing using Turbine 1.0.0 APIs |
| SchemaSourceViewModelTest.kt | Updated test structure with new flow assertions and removed nested test blocks |
| PragmaSourceViewModelTest.kt | Refactored to match new test patterns with Turbine 1.0.0 |
| HistoryViewModelTest.kt | Updated test flows and replaced deprecated Turbine methods |
| EditViewModelTest.kt | Migrated to new test syntax with updated flow handling |
| RenameDatabaseViewModelTest.kt | Refactored with new flow assertion patterns |
| RemoveDatabaseViewModelTest.kt | Updated to use new test structure |
| DatabaseViewModelTest.kt | Added dispatcher management and refactored test flows |
| ContentViewModelTest.kt | Migrated to new test patterns with updated Turbine APIs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 8 comments.
Comments suppressed due to low confidence (2)
dbinspector/src/test/kotlin/com/infinum/dbinspector/ui/edit/EditViewModelTest.kt:296
- This test that is marked as @disabled was not refactored to the new test pattern. It still uses the old nested
testblocks. Since the test is disabled, it should either be updated to the new pattern for consistency or removed if it's no longer needed.
@Test
@Disabled("Unfinished coroutines during teardown.")
fun `Get all history`() {
val useCase: UseCases.GetHistory = get()
val viewModel = EditViewModel(
get(),
get(),
get(),
get(),
get(),
get(),
get(),
useCase,
get(),
get()
).apply {
databasePath = "test.db"
}
coEvery { useCase.invoke(any()) } returns mockk()
test {
viewModel.history()
}
coVerify(exactly = 1) { useCase.invoke(any()) }
test {
viewModel.stateFlow.test {
assertNull(awaitItem())
}
viewModel.eventFlow.test {
val item: EditEvent? = awaitItem()
assertTrue(item is EditEvent.History)
assertNotNull(item.history)
cancelAndIgnoreRemainingEvents()
}
viewModel.errorFlow.test {
expectNoEvents()
}
}
}
dbinspector/src/test/kotlin/com/infinum/dbinspector/ui/edit/EditViewModelTest.kt:337
- This test that is marked as @disabled was not refactored to the new test pattern. It still uses the old nested
testblocks. Since the test is disabled, it should either be updated to the new pattern for consistency or removed if it's no longer needed.
@Test
@Disabled("How to test with delay")
fun `Find similar execution`() {
test {
val useCase: UseCases.GetSimilarExecution = get()
val viewModel = EditViewModel(
get(),
get(),
get(),
get(),
get(),
get(),
get(),
get(),
useCase,
get()
).apply {
databasePath = "test.db"
}
coEvery { useCase.invoke(any()) } returns mockk()
viewModel.findSimilarExecution(TestScope(), "my_execution")
coVerify(exactly = 1) { useCase.invoke(any()) }
viewModel.stateFlow.test {
assertNull(awaitItem())
}
viewModel.eventFlow.test {
val item: EditEvent? = awaitItem()
assertTrue(item is EditEvent.SimilarExecution)
assertNotNull(item.history)
cancelAndIgnoreRemainingEvents()
}
viewModel.errorFlow.test {
expectNoEvents()
}
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
There seem to be flaky tests 😅 |



📄 Context
I used agentic AI to help fix all unit tests.
📝 Changes
Test Library Updates:
Coroutines: 1.6.4 → 1.7.3
Turbine: 0.12.0 → 1.0.0
Pattern for fix
📎 Related PR
🚫 Breaking
🛠️ How to test
⏱️ Next steps
I will read CoPilot's review and fix things if needed