diff --git a/adam/src/main/kotlin/com/malinskiy/adam/request/testrunner/transform/InstrumentationResponseTransformer.kt b/adam/src/main/kotlin/com/malinskiy/adam/request/testrunner/transform/InstrumentationResponseTransformer.kt index fa0681858..4f873b04b 100644 --- a/adam/src/main/kotlin/com/malinskiy/adam/request/testrunner/transform/InstrumentationResponseTransformer.kt +++ b/adam/src/main/kotlin/com/malinskiy/adam/request/testrunner/transform/InstrumentationResponseTransformer.kt @@ -176,7 +176,6 @@ class InstrumentationResponseTransformer : ProgressiveResponseTransformer acc + "\n" + s }) - .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_3.expected").reader().readText()) + .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_3.expected").reader().readText().trimEnd()) } } @@ -66,7 +66,7 @@ class InstrumentationResponseTransformerTest { transformer.transform()?.let { events.addAll(it) } assertThat(events.map { it.toString() }.reduce { acc, s -> acc + "\n" + s }) - .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_2.expected").reader().readText()) + .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_2.expected").reader().readText().trimEnd()) } } @@ -87,7 +87,7 @@ class InstrumentationResponseTransformerTest { transformer.transform()?.let { events.addAll(it) } assertThat(events.map { it.toString() }.reduce { acc, s -> acc + "\n" + s }) - .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_1.expected").reader().readText()) + .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_1.expected").reader().readText().trimEnd()) } } @@ -138,7 +138,7 @@ class InstrumentationResponseTransformerTest { transformer.transform()?.let { events.addAll(it) } assertThat(events.map { it.toString() }.reduce { acc, s -> acc + "\n" + s }) - .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_5.expected").reader().readText()) + .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_5.expected").reader().readText().trimEnd()) } } @@ -161,7 +161,7 @@ class InstrumentationResponseTransformerTest { transformer.transform()?.let { events.addAll(it) } assertThat(events.map { it.toString() }.reduce { acc, s -> acc + "\n" + s }) - .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_6.expected").reader().readText().trimEnd()) + .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_6.expected").reader().readText().trimEnd().trimEnd()) } @Test @@ -186,7 +186,7 @@ class InstrumentationResponseTransformerTest { transformer.transform()?.let { events.addAll(it) } assertThat(events.map { it.toString() }.reduce { acc, s -> acc + "\n" + s }) - .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_6.expected").reader().readText().trimEnd()) + .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_6.expected").reader().readText().trimEnd().trimEnd()) } /** @@ -208,7 +208,7 @@ class InstrumentationResponseTransformerTest { transformer.transform()?.let { events.addAll(it) } assertThat(events.map { it.toString() }.reduce { acc, s -> acc + "\n" + s }) - .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_3.expected").reader().readText()) + .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_3.expected").reader().readText().trimEnd()) } @Test @@ -290,4 +290,20 @@ class InstrumentationResponseTransformerTest { assertThat(events.map { it.toString() }.reduce { acc, s -> acc + "\n" + s }) .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_11.expected").reader().readText().trimEnd()) } + + @Test + fun testSingleIgnoredTest() = runBlocking { + val transformer = InstrumentationResponseTransformer() + val lines = javaClass.getResourceAsStream("/instrumentation/log_12.input").reader().readText() + + val events = mutableListOf() + val bytes = (lines).toByteArray(Const.DEFAULT_TRANSPORT_ENCODING) + transformer.process(bytes, 0, bytes.size)?.let { + events.addAll(it) + } + transformer.transform()?.let { events.addAll(it) } + + assertThat(events.map { it.toString() }.reduce { acc, s -> acc + "\n" + s }) + .isEqualTo(javaClass.getResourceAsStream("/instrumentation/log_12.expected").reader().readText().trimEnd()) + } } diff --git a/adam/src/test/resources/instrumentation/log_1.expected b/adam/src/test/resources/instrumentation/log_1.expected index 43f87ef6f..e48c23dfe 100644 --- a/adam/src/test/resources/instrumentation/log_1.expected +++ b/adam/src/test/resources/instrumentation/log_1.expected @@ -36,11 +36,9 @@ TestFailed(id=TestIdentifier(className=com.example.AbstractFailingTest, testName at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)) TestEnded(id=TestIdentifier(className=com.example.AbstractFailingTest, testName=testAlwaysFailing), metrics={}) TestStarted(id=TestIdentifier(className=com.example.ClassIgnoredTest, testName=null)) -TestStarted(id=TestIdentifier(className=com.example.ClassIgnoredTest, testName=null)) TestIgnored(id=TestIdentifier(className=com.example.ClassIgnoredTest, testName=null)) TestEnded(id=TestIdentifier(className=com.example.ClassIgnoredTest, testName=null), metrics={}) TestStarted(id=TestIdentifier(className=com.example.FailedAssumptionTest, testName=ignoreTest)) -TestStarted(id=TestIdentifier(className=com.example.FailedAssumptionTest, testName=ignoreTest)) TestIgnored(id=TestIdentifier(className=com.example.FailedAssumptionTest, testName=ignoreTest)) TestEnded(id=TestIdentifier(className=com.example.FailedAssumptionTest, testName=ignoreTest), metrics={}) TestStarted(id=TestIdentifier(className=com.example.FailedAssumptionTest, testName=failedAssumptionTest)) @@ -378,4 +376,4 @@ TestFailed(id=TestIdentifier(className=com.example.TestWithWrongName, testName=t at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:375) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)) TestEnded(id=TestIdentifier(className=com.example.TestWithWrongName, testName=testAlwaysFailing), metrics={}) -TestRunEnded(elapsedTimeMillis=0, metrics={}) \ No newline at end of file +TestRunEnded(elapsedTimeMillis=0, metrics={}) diff --git a/adam/src/test/resources/instrumentation/log_12.expected b/adam/src/test/resources/instrumentation/log_12.expected new file mode 100644 index 000000000..18a8b70dd --- /dev/null +++ b/adam/src/test/resources/instrumentation/log_12.expected @@ -0,0 +1,5 @@ +TestRunStartedEvent(testCount=1) +TestStarted(id=TestIdentifier(className=com.example.ClassIgnoredTest, testName=null)) +TestIgnored(id=TestIdentifier(className=com.example.ClassIgnoredTest, testName=null)) +TestEnded(id=TestIdentifier(className=com.example.ClassIgnoredTest, testName=null), metrics={}) +TestRunEnded(elapsedTimeMillis=1, metrics={}) diff --git a/adam/src/test/resources/instrumentation/log_12.input b/adam/src/test/resources/instrumentation/log_12.input new file mode 100644 index 000000000..01915e500 --- /dev/null +++ b/adam/src/test/resources/instrumentation/log_12.input @@ -0,0 +1,25 @@ +INSTRUMENTATION_STATUS: class=com.example.ClassIgnoredTest +INSTRUMENTATION_STATUS: current=1 +INSTRUMENTATION_STATUS: id=AndroidJUnitRunner +INSTRUMENTATION_STATUS: numtests=1 +INSTRUMENTATION_STATUS: stream= +com.example.ClassIgnoredTest: +INSTRUMENTATION_STATUS: test=null +INSTRUMENTATION_STATUS_CODE: 1 +INSTRUMENTATION_STATUS: class=com.example.ClassIgnoredTest +INSTRUMENTATION_STATUS: current=1 +INSTRUMENTATION_STATUS: id=AndroidJUnitRunner +INSTRUMENTATION_STATUS: numtests=1 +INSTRUMENTATION_STATUS: stream= +com.example.ClassIgnoredTest: +INSTRUMENTATION_STATUS: test=null +INSTRUMENTATION_STATUS_CODE: -3 +INSTRUMENTATION_RESULT: stream= + +Time: 0.001 + +OK (0 tests) + + +Error: Failed to generate Emma/JaCoCo coverage. +INSTRUMENTATION_CODE: -1