diff --git a/CHANGELOG.md b/CHANGELOG.md index 59602f706..10a398072 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ We use [semantic versioning](http://semver.org/): - [fix] _teamscale-gradle-plugin_, _teamscale-maven-plugin_: Testwise coverage reports no longer drop a class directory that contains an archive (JAR, WAR, EAR, ZIP) that contains a JAR. - [fix] _agent_: With `duplicates=FAIL`, the error for a duplicate, non-identical class now names the class and how to resolve the problem. - [fix] _agent_, _teamscale-gradle-plugin_, _teamscale-maven-plugin_: A corrupt class file whose class name cannot be read is skipped with a warning instead of failing the coverage report. +- [fix] _impacted-test-engine_: A test that a failing assumption aborts is reported as skipped instead of as an error. # 39.0.0 - [breaking] _agent_: The deprecated Docker image `cqse/teamscale-jacoco-agent` is no longer published. Use `cqse/teamscale-java-profiler` instead, which has replaced it since version 36.5.0. diff --git a/impacted-test-engine/src/main/kotlin/com/teamscale/test_impacted/engine/executor/TestwiseCoverageCollectingExecutionListener.kt b/impacted-test-engine/src/main/kotlin/com/teamscale/test_impacted/engine/executor/TestwiseCoverageCollectingExecutionListener.kt index 29cdc9d82..1dfe828cc 100644 --- a/impacted-test-engine/src/main/kotlin/com/teamscale/test_impacted/engine/executor/TestwiseCoverageCollectingExecutionListener.kt +++ b/impacted-test-engine/src/main/kotlin/com/teamscale/test_impacted/engine/executor/TestwiseCoverageCollectingExecutionListener.kt @@ -175,7 +175,7 @@ class TestwiseCoverageCollectingExecutionListener( ) TestExecutionResult.Status.ABORTED -> TestExecution( - testUniformPath, duration, ETestExecutionResult.ERROR, message + testUniformPath, duration, ETestExecutionResult.SKIPPED, message ) TestExecutionResult.Status.FAILED -> TestExecution( diff --git a/impacted-test-engine/src/test/kotlin/com/teamscale/test_impacted/engine/executor/TestwiseCoverageCollectingExecutionListenerTest.kt b/impacted-test-engine/src/test/kotlin/com/teamscale/test_impacted/engine/executor/TestwiseCoverageCollectingExecutionListenerTest.kt index d932266cb..aebcc5553 100644 --- a/impacted-test-engine/src/test/kotlin/com/teamscale/test_impacted/engine/executor/TestwiseCoverageCollectingExecutionListenerTest.kt +++ b/impacted-test-engine/src/test/kotlin/com/teamscale/test_impacted/engine/executor/TestwiseCoverageCollectingExecutionListenerTest.kt @@ -17,6 +17,7 @@ import org.junit.platform.engine.EngineExecutionListener import org.junit.platform.engine.TestExecutionResult import org.junit.platform.engine.UniqueId import org.mockito.kotlin.* +import org.opentest4j.TestAbortedException /** Tests for [TestwiseCoverageCollectingExecutionListener]. */ internal class TestwiseCoverageCollectingExecutionListenerTest { @@ -262,6 +263,25 @@ internal class TestwiseCoverageCollectingExecutionListenerTest { .doesNotContain("null") } + /** A failing assumption aborts the test, so the test is reported as skipped together with the assumption's message. */ + @Test + fun testAbortedTestIsReportedAsSkipped() { + val jupiterRootId = UniqueId.forEngine("junit-jupiter") + val testClassId = jupiterRootId.append(CLASS_SEGMENT_TYPE, "example.AssumptionTest") + val testCase = SimpleTestDescriptor.testCase(testClassId.append(METHOD_SEGMENT_TYPE, "testA()")) + val testClass = SimpleTestDescriptor.testContainer(testClassId, testCase) + val testRoot = SimpleTestDescriptor.testContainer(jupiterRootId, testClass) + + val listener = jupiterListener() + listOf(testRoot, testClass, testCase).forEach { listener.executionStarted(it) } + listener.executionFinished(testCase, TestExecutionResult.aborted(TestAbortedException("assumption was not met"))) + listOf(testClass, testRoot).forEach { listener.executionFinished(it, TestExecutionResult.successful()) } + + Assertions.assertThat(listener.testExecutions.map { it.uniformPath to it.result }) + .containsExactly("example/AssumptionTest/testA()" to ETestExecutionResult.SKIPPED) + Assertions.assertThat(listener.testExecutions.single().message).contains("assumption was not met") + } + /** The tests of a skipped `@ParameterizedClass` are no longer in the test tree, but must still be reported. */ @Test fun testSkipOfParameterizedClass() {