Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Rm stopTestCase/writeTestCase from testWithException (#41)
Browse files Browse the repository at this point in the history
* rfr AllureAndroidListener.kt

* rm stop/write case for testWithException

* return Result?
  • Loading branch information
viclovsky authored Oct 30, 2019
1 parent 7cfd79b commit c2c1e25
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ open class AllureRunListener(private val lifecycle: AllureLifecycle = AllureComm
* @param result the summary of the test run, including all the tests that failed
*/
@Throws(Exception::class)
override fun testRunFinished(result: Result) {
// do nothing
override fun testRunFinished(result: Result?) {
testRunFinished()
}

fun testRunFinished() {
Expand Down Expand Up @@ -118,12 +118,7 @@ open class AllureRunListener(private val lifecycle: AllureLifecycle = AllureComm
*/
@Throws(Exception::class)
override fun testFailure(failure: Failure) {
if (failure.description.isTest) {
val uuid = getUUIDTestResult(failure.description)
testWithException(uuid, failure)
} else {
suiteWithException(failure)
}
testWithException(failure)
}

/**
Expand All @@ -135,7 +130,16 @@ open class AllureRunListener(private val lifecycle: AllureLifecycle = AllureComm
*/
@Throws(Exception::class)
override fun testAssumptionFailure(failure: Failure) {
testFailure(failure)
testWithException(failure)
}

private fun testWithException(failure: Failure) {
if (failure.description.isTest) {
val uuid = getUUIDTestResult(failure.description)
testWithException(uuid, failure)
} else {
suiteWithException(failure)
}
}

/**
Expand All @@ -159,6 +163,14 @@ open class AllureRunListener(private val lifecycle: AllureLifecycle = AllureComm
}
}

private fun getIgnoredMessage(description: Description): StatusDetails {
val ignore = description.getAnnotation(Ignore::class.java)
val message = if (ignore?.value?.isNotEmpty() == true)
ignore.value else "Test ignored (without reason)!"

return StatusDetails(message = message)
}

protected open fun finalizeContainer(container: String?) {
with(lifecycle) {
stopTestContainer(container)
Expand All @@ -181,14 +193,6 @@ open class AllureRunListener(private val lifecycle: AllureLifecycle = AllureComm
return container
}

private fun getIgnoredMessage(description: Description): StatusDetails {
val ignore = description.getAnnotation(Ignore::class.java)
val message = if (ignore?.value?.isNotEmpty() == true)
ignore.value else "Test ignored (without reason)!"

return StatusDetails(message = message)
}

private fun createTestResult(description: Description): TestResult = TestResult(
uuid = getUUIDTestResult(description),
historyId = getHistoryId(description),
Expand All @@ -210,8 +214,6 @@ open class AllureRunListener(private val lifecycle: AllureLifecycle = AllureComm
status = Status.fromThrowable(failure.exception)
statusDetails = StatusDetails.fromThrowable(failure.exception)
}
stopTestCase(uuid)
writeTestCase(uuid)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AllureAndroidListener : InstrumentationRunListener() {
}

override fun testRunFinished(result: Result?) {
allureListenerDelegate.testRunFinished()
allureListenerDelegate.testRunFinished(result)
}

override fun testIgnored(description: Description) {
Expand Down

0 comments on commit c2c1e25

Please sign in to comment.