Skip to content

Instantly share code, notes, and snippets.

@phellipealexandre
Last active November 11, 2020 01:45
Show Gist options
  • Save phellipealexandre/08d8f226ce75179311e5858b21fa096a to your computer and use it in GitHub Desktop.
Save phellipealexandre/08d8f226ce75179311e5858b21fa096a to your computer and use it in GitHub Desktop.
Configuração de um Stub utilizando api do MockK.
@Test
fun `Retrieve notes count from server when requested`() {
val notesApiStub = mockk<NotesApi>() //Dublê de teste Stub
val noteRepository = NoteRepository(notesApiStub)
val note = generateDummyNote() //Método privado
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