This file contains hidden or 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 `Track analytics event when creating new note`() { | |
val analyticsWrapperMock = mockk<AnalyticsWrapper>() //Dublê de teste Mock | |
val noteAnalytics = NoteAnalytics(analyticsWrapperMock) | |
noteAnalytics.trackNewNoteEvent(NoteType.Supermarket) | |
//Mock verifica que comportamento específico aconteceu | |
verify(exactly = 1) { analyticsWrapperMock.logEvent("NewNote", "SuperMarket") } | |
} |
This file contains hidden or 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 = 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) |
This file contains hidden or 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 `Track analytics event when creating new note`() { | |
val analyticsWrapperSpy = //Dublê de teste Spy | |
val noteAnalytics = NoteAnalytics(analyticsWrapperSpy) | |
//Spy grava o comportamento por debaixo dos panos | |
noteAnalytics.trackCreateNewNoteEvent(NoteType.Supermarket) | |
//Spy verifica que comportamento ocorreu baseado em implementação interna | |
analyticsWrapperSpy.assertThatNewNoteEventWasRegistered("SuperMarket") |
This file contains hidden or 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 `Track analytics event when creating new note`() { | |
val analyticsWrapperMock = //Dublê de teste Mock | |
val noteAnalytics = NoteAnalytics(analyticsWrapperMock) | |
noteAnalytics.trackNewNoteEvent(NoteType.Supermarket) | |
//Mock verifica que comportamento específico aconteceu | |
verify(exactly = 1) { analyticsWrapperMock.logEvent("NewNote", "SuperMarket") } | |
} |
This file contains hidden or 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 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 |
This file contains hidden or 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) |
This file contains hidden or 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
val dummyPrice = 10.0 //Dummy literal | |
val dummyUniqueCustomerNumber = getUniqueNumber() //Dummy auto gerado |
This file contains hidden or 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 `Update registered note count when registering a new note in empty repository`() { | |
val dummyNote = //Dublê de teste Dummy | |
//Passado apenas preencher o parâmetro, o conteúdo do dublê não é tão relevante | |
noteRepository.registerNote(dummyNote) | |
assertEquals(expected = 1, actual = noteRepository.getNoteCount()) | |
} |
This file contains hidden or 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
.PHONY: app | |
app: | |
[Instruction] |
This file contains hidden or 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
[Command]: [Dependent Command 1] ... [Dependent Command N] | |
(Tab ↹)[Instruction 1] | |
. | |
. | |
. | |
(Tab ↹)[Instruction N] |