Skip to content

Instantly share code, notes, and snippets.

View ProArun's full-sized avatar

Arun Kumar Aditya ProArun

View GitHub Profile
@ProArun
ProArun / Quote.kt
Created August 19, 2023 14:49
Instrumentation testing1
data class Quote(val text:String,val author:String)
@ProArun
ProArun / ParameterizedExample.kt
Created August 19, 2023 14:13
parameterized Test Case
@RunWith(value = Parameterized::class)
class ParameterizedExample(val input:String,val expectedValue:Boolean){
@Test
fun test(){
val helper = Helper()
val result = helper.isPallindrome(input)
assertEquals(expectedValue,result)
}
class Helper {
fun isPallindrome(input: String): Boolean{
var i = 0
var j = input.length - 1
var result = true
while (i < j){
if(input[i] != input[j]){
result = false
break
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest{
@Test
fun useAppContext(){
//Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.cheezycode.unittestingexample", appContext.packageName)
}
}
@ProArun
ProArun / ExampleUnitTest.kt
Last active August 19, 2023 13:36
Unit Test 1
class ExampleUnitTest{
@Test
fun addition_isCorrect(){
assertEquals(expected:4,actual:2+2)
}
}