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
data class Quote(val text:String,val author:String) |
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
@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) | |
} | |
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 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 |
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
@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) | |
} | |
} |
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 ExampleUnitTest{ | |
@Test | |
fun addition_isCorrect(){ | |
assertEquals(expected:4,actual:2+2) | |
} | |
} |
NewerOlder