Skip to content

Instantly share code, notes, and snippets.

@phellipealexandre
Last active November 14, 2020 11:29
Show Gist options
  • Save phellipealexandre/3bf4e745ff69f71034d18efbe08d8ef5 to your computer and use it in GitHub Desktop.
Save phellipealexandre/3bf4e745ff69f71034d18efbe08d8ef5 to your computer and use it in GitHub Desktop.
Exemplo onde substituímos a dependência de uma API por um Fake. O comportamento desse Fake estará implementado na própria classe FakeNoteApi.
@Test
fun `Retrieve all notes when requested`() {
//Dublê de teste Fake. Implementa a mesma interface do original.
val noteApiFake = FakeNoteApi()
val noteRepository = NoteRepository(noteApiFake)
val note = //Dublê de teste Dummy
noteApiFake.uploadNote(note)
noteApiFake.uploadNote(note)
//Fake será utilizado por debaixo dos panos com uma implementação real
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