Created
February 25, 2019 00:36
-
-
Save jabubuck/c24000536a0ce8b6eb39dfa7972a9616 to your computer and use it in GitHub Desktop.
Self reference for writing unitt tests with mockito
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
import com.nhaarman.mockito_kotlin.mock | |
import com.nhaarman.mockito_kotlin.verify | |
import org.junit.Test | |
class Tests { | |
@Test | |
fun testname_callsfunctionname() { | |
//Instantiate Presenter | |
val presenter = MyPresenter() | |
//Stub the view and attach it | |
val view: MyPresenter.View = mock() | |
presenter.attachView(view) | |
//Test the function | |
presenter.functionToTest(PARAMETER) | |
//Verify view has done something | |
verify(view).functionName() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment