Skip to content

Commit

Permalink
Merge pull request #550 from MarathonLabs/fix/android-ignored-test
Browse files Browse the repository at this point in the history
fix(android): invoke before/after test run lifecycle hooks when test …
  • Loading branch information
Malinskiy committed Aug 31, 2021
2 parents 50ba1c6 + fc5a9d4 commit 86b63bb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ class AndroidDeviceTestRunner(private val device: AdamAndroidDevice, private val
val ignoredTests = rawTestBatch.tests.filter { test -> test.isIgnored() }
val testBatch = TestBatch(rawTestBatch.tests - ignoredTests, rawTestBatch.id)
if (testBatch.tests.isEmpty()) {
listener.beforeTestRun()
notifyIgnoredTest(ignoredTests, listener)
listener.testRunEnded(0, emptyMap())
listener.afterTestRun()
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ class AndroidDeviceTestRunner(private val device: DdmlibAndroidDevice, private v
val testBatch = TestBatch(rawTestBatch.tests - ignoredTests)
val listenerAdapter = listener.toDdmlibTestListener()
if (testBatch.tests.isEmpty()) {
listener.beforeTestRun()
notifyIgnoredTest(ignoredTests, listenerAdapter)
listener.testRunEnded(0, emptyMap())
listener.afterTestRun()
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,12 @@ class AndroidDeviceTestRunnerTest {
val listener = mock<AndroidTestRunListener>()
runBlocking {
androidDeviceTestRunner.execute(configuration, batch, listener)
verify(listener).beforeTestRun()
verify(listener).testStarted(eq(identifier))
verify(listener).testIgnored(eq(identifier))
verify(listener).testEnded(eq(identifier), eq(emptyMap()))
verify(listener).testRunEnded(eq(0), eq(emptyMap()))
verify(listener).afterTestRun()
}
verifyNoMoreInteractions(listener)
}
Expand Down

0 comments on commit 86b63bb

Please sign in to comment.