Skip to content

Commit 7deec26

Browse files
author
oyanushkevich
committed
Add ability to capture output for failed tests.
1 parent bc18989 commit 7deec26

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Allure.Xunit/AllureXunitConfiguration.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ namespace Allure.Xunit
1212
internal class AllureXunitConfiguration : AllureConfiguration
1313
{
1414
public string XunitRunnerReporter { get; set; } = "auto";
15+
16+
public bool CaptureFailedTestOutput { get; set; } = false;
1517

1618
[JsonConstructor]
1719
protected AllureXunitConfiguration(

Allure.Xunit/AllureXunitHelper.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,16 @@ internal static void StartAllureTestCase(
3333
testResult ?? CreateTestResultByTest(test)
3434
);
3535

36-
internal static void ApplyTestFailure(IFailureInformation failure)
36+
internal static void ApplyTestFailure(ITestFailed failure)
3737
{
3838
var trace = string.Join("\n", failure.StackTraces);
3939
var message = string.Join("\n", failure.Messages);
40+
41+
if (AllureXunitConfiguration.CurrentConfig.CaptureFailedTestOutput)
42+
{
43+
message = string.Concat(message, "\n", failure.Output);
44+
}
45+
4046
var status = failure.ExceptionTypes.Any(
4147
exceptionType => !exceptionType.StartsWith("Xunit.Sdk.")
4248
) ? Status.broken : Status.failed;

0 commit comments

Comments
 (0)