Skip to content

Commit

Permalink
Fix RunAndroidTestsKtTest
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-goral committed May 27, 2020
1 parent 0cc3300 commit b6996d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package ftl.run.platform

import ftl.args.AndroidArgs
import ftl.json.MatrixMap
import ftl.test.util.FlankTestRunner
import ftl.test.util.mixedConfigYaml
import ftl.test.util.should
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(FlankTestRunner::class)
class RunAndroidTestsKtTest {

@Test
Expand Down
7 changes: 7 additions & 0 deletions test_runner/src/test/kotlin/ftl/test/util/TestHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,19 @@ inline fun <reified T : Any> ignore(): T = mockk(relaxed = true) {

inline fun <reified T : Any> should(crossinline match: T.() -> Boolean): T = mockk(relaxed = true) {
val slot = slot<T>()
var matched = false
every { this@mockk == capture(slot) } answers {
val value = slot.captured
value.match().also { matches ->
matched = matches
if (matches)
println("${this@mockk} match succeed: $value") else
println("${this@mockk} match failed: $value")
}
}
every { this@mockk.toString() } answers {
if (matched && slot.isCaptured)
slot.captured.toString() else
callOriginal()
}
}

0 comments on commit b6996d8

Please sign in to comment.