Last active
November 14, 2020 11:26
-
-
Save phellipealexandre/9e75b857d30d7b27339ca1168b665857 to your computer and use it in GitHub Desktop.
Exemplo onde substituímos a dependência de uma API por um Stub e configuramos o retorno desse Stub para ser uma resposta fixa.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun `Retrieve notes count from server when requested`() { | |
val notesApiStub = //Dublê de teste Stub | |
val noteRepository = NoteRepository(notesApiStub) | |
//Configuração do Stub. Valor hard-coded retornado será uma lista com 2 notas. | |
//Esse método será chamado pelo noteRepository.getNoteCount() | |
val note = //Dublê de teste Dummy | |
every { notesApiStub.fetchAllNotes() } returns listOf(note, note) | |
val allNotesCount = noteRepository.getNoteCount() | |
assertEquals(expected = 2, actual = allNotesCount) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment