-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Learnt something new about paramterised test cases
- Loading branch information
1 parent
ef75229
commit c917464
Showing
8 changed files
with
102 additions
and
26 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...ng_the_service/ExampleInstrumentedTest.kt → ...example/audify/ExampleInstrumentedTest.kt
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
20 changes: 0 additions & 20 deletions
20
app/src/androidTest/java/com/example/scrutinizing_the_service/TestDispatcherProvider.kt
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.example.audify | ||
|
||
class Sample { | ||
|
||
|
||
fun isPalindrome(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 | ||
} | ||
|
||
i++ | ||
j-- | ||
} | ||
return result | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...zing_the_service/utils/ExampleUnitTest.kt → ...ava/com/example/audify/ExampleUnitTest.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.example.scrutinizing_the_service.utils | ||
package com.example.audify | ||
|
||
import org.junit.Test | ||
|
||
|
36 changes: 36 additions & 0 deletions
36
app/src/test/java/com/example/audify/ParameterizedSampleTest.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.example.audify | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.Parameterized | ||
import org.junit.runners.Parameterized.Parameters | ||
|
||
@RunWith(value = Parameterized::class) | ||
class ParameterizedSampleTest( | ||
val input: String, | ||
val expectedValue: Boolean | ||
) { | ||
|
||
@Test | ||
fun test() { | ||
val sample = Sample() | ||
val result = sample.isPalindrome(input = input) | ||
assertEquals(result, expectedValue) | ||
} | ||
|
||
companion object { | ||
|
||
@JvmStatic | ||
@Parameters(name = "{index} : {0} is palindrome - {1}") | ||
fun data(): List<Array<Any>> { | ||
return listOf( | ||
arrayOf("Hellow", false), | ||
arrayOf("level", true), | ||
arrayOf("m", true), | ||
arrayOf("", true), | ||
) | ||
} | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.example.audify | ||
|
||
import org.junit.After | ||
import org.junit.Assert | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
|
||
class SampleTest { | ||
|
||
lateinit var sample: Sample | ||
|
||
@Before | ||
fun setup() { | ||
sample = Sample() | ||
} | ||
|
||
@Test | ||
fun isPalindrome_input_hello_expect_false() { | ||
// Arrange | ||
// Act | ||
val result = sample.isPalindrome("Hello") | ||
// Assert | ||
Assert.assertEquals(false, result) | ||
} | ||
|
||
@Test | ||
fun isPalindrome_input_level_expect_true() { | ||
// Arrange | ||
// Act | ||
val result = sample.isPalindrome("level") | ||
// Assert | ||
Assert.assertEquals(true, result) | ||
} | ||
|
||
@After | ||
fun tearDown() { | ||
println("After running the test") | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...vice/utils/WelcomeScreenScreenshotTest.kt → ...ple/audify/WelcomeScreenScreenshotTest.kt
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