Exercise: Unit testing
Implement unit tests for the SynchronizeUserUseCase
class in SynchronizeUserUseCaseTest
using fake objects.
class CorrectCardsUseCase(
private val view: AnkiView,
private val cardsRepository: AnkiCardsRepository,
) {
suspend fun start() {
val progressBar = AnkiProgressBar(size = Small)
view.show(progressBar)
try {
cardsRepository.correctCards()
} finally {
view.hide(progressBar)
}
val dialog = AnkiDialog(
title = "Success",
text = "Cards correction successful",
okButton = AnkiDialog.Button("OK"),
)
view.show(dialog)
}
}
Use CorrectCardsUseCaseTest
and SynchronizeCardsUseCaseTest
as inspiration. You can find those classes in the repository MarcinMoskala/kotlin-exercises in the package effective.anki
.
Marcin Moskala is a highly experienced developer and Kotlin instructor as the founder of Kt. Academy, an official JetBrains partner specializing in Kotlin training, Google Developers Expert, known for his significant contributions to the Kotlin community. Moskala is the author of several widely recognized books, including "Effective Kotlin," "Kotlin Coroutines," "Functional Kotlin," "Advanced Kotlin," "Kotlin Essentials," and "Android Development with Kotlin."
Beyond his literary achievements, Moskala is the author of the largest Medium publication dedicated to Kotlin. As a respected speaker, he has been invited to share his insights at numerous programming conferences, including events such as Droidcon and the prestigious Kotlin Conf, the premier conference dedicated to the Kotlin programming language.