Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,26 @@ public void error(final ErrorInfo error) {
if (Objects.isNull(uuid)) {
return;
}
getLifecycle().updateTest(
testKey(uuid), testResult -> testResult
.setStatus(getStatus(error.getException()).orElse(null))
.setStatusDetails(getStatusDetails(error.getException()).orElse(null))
);
final Throwable exception = error.getException();
getLifecycle().updateTest(testKey(uuid), testResult -> {
testResult.setStatus(getStatus(exception).orElse(null));

final StatusDetails details = getStatusDetails(exception).orElse(null);
if (Objects.isNull(details)) {
return;
}
// merge the exception details into the existing status details so that
// the flaky/muted flags set in beforeIteration are not overwritten
final StatusDetails current = testResult.getStatusDetails();
if (Objects.isNull(current)) {
testResult.setStatusDetails(details);
} else {
current.setMessage(details.getMessage())
.setTrace(details.getTrace())
.setActual(details.getActual())
.setExpected(details.getExpected());
}
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import io.qameta.allure.spock2.samples.DataDrivenTest;
import io.qameta.allure.spock2.samples.DerivedSpec;
import io.qameta.allure.spock2.samples.FailedTest;
import io.qameta.allure.spock2.samples.FailedTestWithAnnotations;
import io.qameta.allure.spock2.samples.FixturesTest;
import io.qameta.allure.spock2.samples.HelloSpockSpec;
import io.qameta.allure.spock2.samples.OneTest;
Expand Down Expand Up @@ -356,6 +357,21 @@ void shouldProcessMutedAnnotation() {
);
}

@Test
void shouldKeepFlakyAndMutedForFailedTest() {
final AllureResults results = runClasses(FailedTestWithAnnotations.class);
assertThat(results.getTestResults())
.extracting(
TestResult::getName,
TestResult::getStatus,
tr -> tr.getStatusDetails().isFlaky(),
tr -> tr.getStatusDetails().isMuted()
)
.containsExactly(
tuple("failedTest", Status.FAILED, true, true)
);
}

@Test
void shouldSetDisplayName() {
final AllureResults results = runClasses(OneTest.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2016-2026 Qameta Software Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.qameta.allure.spock2.samples

import io.qameta.allure.Flaky
import io.qameta.allure.Muted
import spock.lang.Specification

class FailedTestWithAnnotations extends Specification {

@Flaky
@Muted
def "failedTest"() {
expect:
false
}
}
Loading