|
26 | 26 | import io.qameta.allure.model.StepResult; |
27 | 27 | import io.qameta.allure.model.TestResult; |
28 | 28 | import io.qameta.allure.model.TestResultContainer; |
| 29 | +import io.qameta.allure.spock2.samples.CleanupAttachmentFailedTest; |
29 | 30 | import io.qameta.allure.spock2.samples.BrokenTest; |
30 | 31 | import io.qameta.allure.spock2.samples.DataDrivenTest; |
31 | 32 | import io.qameta.allure.spock2.samples.DerivedSpec; |
|
64 | 65 | import org.mockito.ArgumentCaptor; |
65 | 66 |
|
66 | 67 | import java.lang.reflect.Method; |
| 68 | +import java.nio.charset.StandardCharsets; |
67 | 69 | import java.time.Instant; |
68 | 70 | import java.util.Arrays; |
69 | 71 | import java.util.Collection; |
@@ -245,6 +247,22 @@ void shouldProcessFailedTest() { |
245 | 247 | .containsExactly(Status.FAILED); |
246 | 248 | } |
247 | 249 |
|
| 250 | + @Test |
| 251 | + void shouldAttachCleanupAttachmentOnFailedTest() { |
| 252 | + final AllureResults results = runClasses(CleanupAttachmentFailedTest.class); |
| 253 | + final TestResult testResult = results.getTestResultByName("failed test with cleanup attachment"); |
| 254 | + |
| 255 | + assertThat(testResult.getStatus()).isEqualTo(Status.FAILED); |
| 256 | + assertThat(testResult.getAttachments()) |
| 257 | + .extracting(io.qameta.allure.model.Attachment::getName, io.qameta.allure.model.Attachment::getType) |
| 258 | + .containsExactly(tuple("cleanup attachment", "text/plain")); |
| 259 | + |
| 260 | + final String source = testResult.getAttachments().get(0).getSource(); |
| 261 | + assertThat(results.getAttachments()).containsKey(source); |
| 262 | + assertThat(results.getAttachments().get(source)) |
| 263 | + .containsExactly("attachment from cleanup".getBytes(StandardCharsets.UTF_8)); |
| 264 | + } |
| 265 | + |
248 | 266 | @Test |
249 | 267 | void shouldProcessBrokenTest() { |
250 | 268 | final AllureResults results = runClasses(BrokenTest.class); |
|
0 commit comments