Skip to content

Commit

Permalink
fix for issue 990 (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
OsirisTerje authored Jul 11, 2022
1 parent 6a6e422 commit 5d5b5de
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
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

0 comments on commit 5d5b5de

Please sign in to comment.