Created
August 19, 2023 17:38
-
-
Save ProArun/00ebf801b8fce1af8e8bb40cf1b5e581 to your computer and use it in GitHub Desktop.
convert instrumentation test to jvm test
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
class QuoteManagerTest{ | |
@Mock | |
lateinit var context: Context | |
@Mock | |
lateinit var assertManager: AssertManager | |
@Before | |
fun setup(){ | |
MockitoAnnotations.openMocks(testClass:this) | |
} | |
@Test | |
fun test(){ | |
val testStream = QuoteManagerTest::class.java.getResourceAsStream("/quotes.json")//add quotes.json in test/resources folder | |
doReturn(assertManager).`when`(context).asserts | |
Mockito.`when`(context.asserts.open(anyString())).thenReturn(testStream) | |
val sut = QuoteManager() | |
sut.populateQuoteFromAssets(context,"fileName: "") | |
val quote = sut.getCurrentQuote() | |
Assert.assertEquals("Well begun is half done",quote.text) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment