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

Add stacktrace to ignored tests reports (#112). #115

Merged
merged 3 commits into from
Nov 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Expand Up @@ -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 -> {
Expand Down
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
Expand Up @@ -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()
}
}
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
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
Expand Up @@ -58,15 +58,25 @@ class JUnitReportSpec : Spek({
adbDevice = adbDevice,
className = "test.class.name4",
testName = "test4",
status = Ignored,
status = Ignored(""),
Copy link
Contributor

@yunikkk yunikkk Nov 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems it would be nice to add smth and check it as failed statuses are checked, too

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
Expand All @@ -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">
Expand All @@ -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"
)
Expand Down