Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Commit

Permalink
Add stacktrace to ignored tests reports (#112). (#115)
Browse files Browse the repository at this point in the history
* Add stacktrace to ignored tests reports (#112).

* Add Ignored test stacktrace to JUnit report test.

* Add ignored test with stacktrace to JUnit report test.
koral-- authored and yunikkk committed Nov 22, 2017
1 parent 25ddfa0 commit dc33103
Showing 4 changed files with 33 additions and 9 deletions.
10 changes: 8 additions & 2 deletions composer/src/main/kotlin/com/gojuno/composer/JUnitReport.kt
Original file line number Diff line number Diff line change
@@ -45,9 +45,15 @@ fun writeJunit4Report(suite: Suite, outputFile: File): Completable = Single
Passed -> {
appendln("/>")
}
Ignored -> {
is Ignored -> {
appendln(">")
appendln("<skipped/>")
if (test.status.stacktrace.isEmpty()) {
appendln("<skipped/>")
} else {
appendln("<skipped>")
appendln(StringEscapeUtils.escapeXml10(test.status.stacktrace))
appendln("</skipped>")
}
appendln("</testcase>")
}
is Failed -> {
4 changes: 2 additions & 2 deletions composer/src/main/kotlin/com/gojuno/composer/TestRun.kt
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ data class AdbDeviceTest(
) {
sealed class Status {
object Passed : Status()
object Ignored : Status()
data class Ignored(val stacktrace: String) : Status()
data class Failed(val stacktrace: String) : Status()
}
}
@@ -106,7 +106,7 @@ fun AdbDevice.runTests(
testName = test.testName,
status = when (test.status) {
is InstrumentationTest.Status.Passed -> AdbDeviceTest.Status.Passed
is InstrumentationTest.Status.Ignored -> AdbDeviceTest.Status.Ignored
is InstrumentationTest.Status.Ignored -> AdbDeviceTest.Status.Ignored(test.status.stacktrace)
is InstrumentationTest.Status.Failed -> AdbDeviceTest.Status.Failed(test.status.stacktrace)
},
durationNanos = test.durationNanos,
Original file line number Diff line number Diff line change
@@ -76,11 +76,12 @@ fun AdbDeviceTest.toHtmlFullTest(suiteId: String, htmlReportDir: File) = HtmlFul
durationMillis = NANOSECONDS.toMillis(durationNanos),
status = when (status) {
AdbDeviceTest.Status.Passed -> HtmlFullTest.Status.Passed
AdbDeviceTest.Status.Ignored -> HtmlFullTest.Status.Ignored
is AdbDeviceTest.Status.Ignored -> HtmlFullTest.Status.Ignored
is AdbDeviceTest.Status.Failed -> HtmlFullTest.Status.Failed
},
stacktrace = when (status) {
is AdbDeviceTest.Status.Failed -> status.stacktrace
is AdbDeviceTest.Status.Ignored -> status.stacktrace
is AdbDeviceTest.Status.Failed -> status.stacktrace
else -> null
},
logcatPath = logcat.relativePathTo(htmlReportDir),
23 changes: 20 additions & 3 deletions composer/src/test/kotlin/com/gojuno/composer/JUnitReportSpec.kt
Original file line number Diff line number Diff line change
@@ -58,15 +58,25 @@ class JUnitReportSpec : Spek({
adbDevice = adbDevice,
className = "test.class.name4",
testName = "test4",
status = Ignored,
status = Ignored(""),
durationNanos = SECONDS.toNanos(0),
logcat = testFile(),
files = emptyList(),
screenshots = emptyList()
),
AdbDeviceTest(
adbDevice = adbDevice,
className = "test.class.name5",
testName = "test5",
status = Ignored("multi\nline\nstacktrace"),
durationNanos = SECONDS.toNanos(0),
logcat = testFile(),
files = emptyList(),
screenshots = emptyList()
)
),
passedCount = 2,
ignoredCount = 1,
ignoredCount = 2,
failedCount = 1,
durationNanos = MILLISECONDS.toNanos(6250),
timestampMillis = 1490200150000
@@ -78,7 +88,7 @@ class JUnitReportSpec : Spek({
it("produces correct xml report") {
assertThat(outputFile.readText()).isEqualTo("""
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="com.gojuno.test" tests="4" failures="1" errors="0" skipped="1" time="6.25" timestamp="2017-03-22T16:29:10" hostname="localhost">
<testsuite name="com.gojuno.test" tests="5" failures="1" errors="0" skipped="2" time="6.25" timestamp="2017-03-22T16:29:10" hostname="localhost">
<properties/>
<testcase classname="test.class.name1" name="test1" time="2.0"/>
<testcase classname="test.class.name2" name="test2" time="3.25">
@@ -92,6 +102,13 @@ class JUnitReportSpec : Spek({
<testcase classname="test.class.name4" name="test4" time="0.0">
<skipped/>
</testcase>
<testcase classname="test.class.name5" name="test5" time="0.0">
<skipped>
multi
line
stacktrace
</skipped>
</testcase>
</testsuite>
""".trimIndent() + "\n"
)

0 comments on commit dc33103

Please sign in to comment.