Skip to content
Open
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
8 changes: 4 additions & 4 deletions allure-spock2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ plugins {
}

val spockFrameworkVersion = "2.3-groovy-3.0"
val groovyVersion = "3.0.22"
val spockTestVersion = "2.4-groovy-4.0"
val groovyVersion = "4.0.29"

dependencies {
api(project(":allure-java-commons"))
Expand All @@ -16,13 +17,13 @@ dependencies {
testAnnotationProcessor(project(":allure-descriptions-javadoc"))
testImplementation("io.github.glytching:junit-extensions")
testImplementation("org.assertj:assertj-core")
testImplementation("org.codehaus.groovy:groovy:${groovyVersion}")
testImplementation("org.apache.groovy:groovy:${groovyVersion}")
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testImplementation("org.junit.platform:junit-platform-launcher")
testImplementation("org.mockito:mockito-core")
testImplementation("org.slf4j:slf4j-simple")
testImplementation("org.spockframework:spock-core:$spockFrameworkVersion")
testImplementation("org.spockframework:spock-core:$spockTestVersion")
testImplementation(project(":allure-assertj"))
testImplementation(project(":allure-java-commons-test"))
testImplementation(project(":allure-junit-platform"))
Expand Down Expand Up @@ -58,4 +59,3 @@ publishing {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.qameta.allure.model.StepResult;
import io.qameta.allure.model.TestResult;
import io.qameta.allure.model.TestResultContainer;
import io.qameta.allure.spock2.samples.CleanupAttachmentFailedTest;
import io.qameta.allure.spock2.samples.BrokenTest;
import io.qameta.allure.spock2.samples.DataDrivenTest;
import io.qameta.allure.spock2.samples.DerivedSpec;
Expand Down Expand Up @@ -64,6 +65,7 @@
import org.mockito.ArgumentCaptor;

import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -245,6 +247,22 @@ void shouldProcessFailedTest() {
.containsExactly(Status.FAILED);
}

@Test
void shouldAttachCleanupAttachmentOnFailedTest() {
final AllureResults results = runClasses(CleanupAttachmentFailedTest.class);
final TestResult testResult = results.getTestResultByName("failed test with cleanup attachment");

assertThat(testResult.getStatus()).isEqualTo(Status.FAILED);
assertThat(testResult.getAttachments())
.extracting(io.qameta.allure.model.Attachment::getName, io.qameta.allure.model.Attachment::getType)
.containsExactly(tuple("cleanup attachment", "text/plain"));

final String source = testResult.getAttachments().get(0).getSource();
assertThat(results.getAttachments()).containsKey(source);
assertThat(results.getAttachments().get(source))
.containsExactly("attachment from cleanup".getBytes(StandardCharsets.UTF_8));
}

@Test
void shouldProcessBrokenTest() {
final AllureResults results = runClasses(BrokenTest.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.Allure
import spock.lang.Specification

class CleanupAttachmentFailedTest extends Specification {

def "failed test with cleanup attachment"() {
expect:
false

cleanup:
Allure.addAttachment("cleanup attachment", "text/plain", "attachment from cleanup", ".txt")
}
}
Loading