|
27 | 27 | import org.opentest4j.AssertionFailedError; |
28 | 28 | import org.opentest4j.ValueWrapper; |
29 | 29 |
|
| 30 | +import java.io.IOException; |
30 | 31 | import java.io.Serializable; |
31 | 32 | import java.lang.annotation.Annotation; |
32 | 33 | import java.util.List; |
|
48 | 49 | import static io.qameta.allure.util.ResultsUtils.createTmsLink; |
49 | 50 | import static io.qameta.allure.util.ResultsUtils.getLinkTypePatternPropertyName; |
50 | 51 | import static org.assertj.core.api.Assertions.assertThat; |
| 52 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
| 53 | +import static org.mockito.Mockito.mock; |
| 54 | +import static org.mockito.Mockito.when; |
| 55 | + |
51 | 56 | @ExtendWith(SystemPropertyExtension.class) |
52 | 57 | class ResultsUtilsTest { |
53 | 58 |
|
@@ -399,6 +404,27 @@ void shouldExtractActualAndExpectedFromOpenTest4jAssertionFailedError() { |
399 | 404 | assertThat(details.getExpected()).startsWith("expected value ("); |
400 | 405 | } |
401 | 406 |
|
| 407 | + @Test |
| 408 | + @Issue("1035") |
| 409 | + void shouldCreateStatusDetailsWhenNestedStackTraceCannotBeRendered() { |
| 410 | + final RuntimeException cause = mock(RuntimeException.class); |
| 411 | + when(cause.getSuppressed()).thenReturn(null); |
| 412 | + final AssertionFailedError error = assertThrows( |
| 413 | + AssertionFailedError.class, |
| 414 | + () -> assertThrows(IOException.class, () -> { |
| 415 | + throw cause; |
| 416 | + }) |
| 417 | + ); |
| 418 | + |
| 419 | + final StatusDetails details = getStatusDetailsFor("malformed nested throwable", error); |
| 420 | + |
| 421 | + assertThat(details.getMessage()).startsWith("Unexpected exception type thrown"); |
| 422 | + assertThat(details.getTrace()) |
| 423 | + .contains(AssertionFailedError.class.getName()) |
| 424 | + .contains("Caused by:") |
| 425 | + .contains("[Unable to render the complete stack trace: java.lang.NullPointerException]"); |
| 426 | + } |
| 427 | + |
402 | 428 | @Test |
403 | 429 | void shouldUseOpenTest4jValueWrapperToString() { |
404 | 430 | final AssertionFailedError error = new AssertionFailedError( |
|
0 commit comments