Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue 990 #992

Merged
merged 1 commit into from
Jul 11, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var configuration = Argument("configuration", "Release");
//////////////////////////////////////////////////////////////////////

var version = "4.3.0";
var modifier = "";
var modifier = "-alpha-107";

var dbgSuffix = configuration.ToLower() == "debug" ? "-dbg" : "";
var packageVersion = version + modifier + dbgSuffix;
Expand Down
17 changes: 12 additions & 5 deletions src/NUnitTestAdapter/NUnitEngine/NUnitTestEventTestCase.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Globalization;
using System.Text;
using System.Xml;
using System.Xml;

namespace NUnit.VisualStudio.TestAdapter.NUnitEngine
{
Expand All @@ -17,6 +14,11 @@ public interface INUnitTestEventTestCase : INUnitTestEvent
/// Find stacktrace in assertion nodes if not defined.
/// </summary>
string StackTrace { get; }

/// <summary>
/// Complete formatted stacktrace
/// </summary>
string FailureStackTrace { get; }
}


Expand Down Expand Up @@ -57,6 +59,9 @@ public NUnitTestEventTestCase(XmlNode node)
public bool HasReason => !string.IsNullOrEmpty(ReasonMessage);
public bool HasFailure => Failure != null;

public string FailureStackTrace => $"{Failure?.Stacktrace ?? ""}\n{StackTrace}";


/// <summary>
/// Find stacktrace in assertion nodes if not defined.
/// </summary>
Expand All @@ -65,9 +70,11 @@ public string StackTrace
get
{
string stackTrace = string.Empty;
int i = 1;
foreach (XmlNode assertionStacktraceNode in Node.SelectNodes("assertions/assertion/stack-trace"))
{
stackTrace += assertionStacktraceNode.InnerText.UnEscapeUnicodeCharacters();
stackTrace += $"{i++}) " + assertionStacktraceNode.InnerText.UnEscapeUnicodeCharacters();
stackTrace += "\n";
}

return stackTrace;
Expand Down
7 changes: 5 additions & 2 deletions src/NUnitTestAdapter/TestConverter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2011-2021 Charlie Poole, Terje Sandstrom
// Copyright (c) 2011-2021 Charlie Poole, 2011 - 2022 Terje Sandstrom
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
Expand All @@ -25,9 +25,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities;

using NUnit.VisualStudio.TestAdapter.NUnitEngine;

using VSTestResult = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult;

namespace NUnit.VisualStudio.TestAdapter
Expand Down Expand Up @@ -108,7 +111,7 @@ public TestConverterForXml.TestResultSet GetVsTestResults(INUnitTestEventTestCas
case TestOutcome.NotFound:
{
testCaseResult.ErrorMessage = resultNode.Failure?.Message;
testCaseResult.ErrorStackTrace = resultNode.Failure?.Stacktrace ?? resultNode.StackTrace;
testCaseResult.ErrorStackTrace = resultNode.FailureStackTrace;
break;
}
case TestOutcome.Skipped:
Expand Down
5 changes: 3 additions & 2 deletions src/NUnitTestAdapter/TestConverterForXml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2011-2021 Charlie Poole, Terje Sandstrom
// Copyright (c) 2011-2021 Charlie Poole, 2011-2022 Terje Sandstrom
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -132,7 +132,8 @@ public TestResultSet GetVsTestResults(INUnitTestEventTestCase resultNode, IColle
case TestOutcome.NotFound:
{
testCaseResult.ErrorMessage = resultNode.Failure?.Message;
testCaseResult.ErrorStackTrace = resultNode.Failure?.Stacktrace ?? resultNode.StackTrace;
testCaseResult.ErrorStackTrace = resultNode.FailureStackTrace;

break;
}
case TestOutcome.Skipped:
Expand Down