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

Issue852 #861

Merged
merged 4 commits into from May 27, 2021
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
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -412,3 +412,4 @@ MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
/dupl.xml
NDependOut/
1 change: 1 addition & 0 deletions .runsettings
Expand Up @@ -3,6 +3,7 @@
<RunConfiguration>
<!-- 0 = As many processes as possible, limited by number of cores on machine, 1 = Sequential (1 process), 2-> Given number of processes up to limit by number of cores on machine-->
<MaxCpuCount>0</MaxCpuCount>

</RunConfiguration>

<!--
Expand Down
13,033 changes: 13,033 additions & 0 deletions NUnit3TestAdapter.ndproj

Large diffs are not rendered by default.

74 changes: 40 additions & 34 deletions src/NUnitTestAdapter/AdapterSettings.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2014-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2014-2021 Charlie Poole, 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 @@ -296,25 +296,11 @@ public void Load(string settingsXml)
Verbosity = GetInnerTextAsInt(nunitNode, nameof(Verbosity), 0);
_logger.Verbosity = Verbosity;

var runConfiguration = doc.SelectSingleNode("RunSettings/RunConfiguration");
MaxCpuCount = GetInnerTextAsInt(runConfiguration, nameof(MaxCpuCount), -1);
ResultsDirectory = GetInnerTextWithLog(runConfiguration, nameof(ResultsDirectory));
TargetPlatform = GetInnerTextWithLog(runConfiguration, nameof(TargetPlatform));
TargetFrameworkVersion = GetInnerTextWithLog(runConfiguration, nameof(TargetFrameworkVersion));
TestAdapterPaths = GetInnerTextWithLog(runConfiguration, nameof(TestAdapterPaths));
CollectSourceInformation = GetInnerTextAsBool(runConfiguration, nameof(CollectSourceInformation), true);
DisableAppDomain = GetInnerTextAsBool(runConfiguration, nameof(DisableAppDomain), false);
DisableParallelization = GetInnerTextAsBool(runConfiguration, nameof(DisableParallelization), false);
DesignMode = GetInnerTextAsBool(runConfiguration, nameof(DesignMode), false);
CollectDataForEachTestSeparately =
GetInnerTextAsBool(runConfiguration, nameof(CollectDataForEachTestSeparately), false);
ExtractRunConfiguration(doc);

TestProperties = new Dictionary<string, string>();
UpdateTestProperties();
UpdateTestProperties(doc);

// NUnit settings
InternalTraceLevel = GetInnerTextWithLog(nunitNode, nameof(InternalTraceLevel), "Off", "Error", "Warning",
"Info", "Verbose", "Debug");
WorkDirectory = GetInnerTextWithLog(nunitNode, nameof(WorkDirectory));
Where = GetInnerTextWithLog(nunitNode, nameof(Where));
DefaultTimeout = GetInnerTextAsInt(nunitNode, nameof(DefaultTimeout), 0);
Expand All @@ -335,30 +321,23 @@ public void Load(string settingsXml)
UseNUnitIdforTestCaseId = GetInnerTextAsBool(nunitNode, nameof(UseNUnitIdforTestCaseId), false);
ConsoleOut = GetInnerTextAsInt(nunitNode, nameof(ConsoleOut), 1); // 0 no output to console, 1 : output to console
StopOnError = GetInnerTextAsBool(nunitNode, nameof(StopOnError), false);
DiscoveryMethod = MapEnum(GetInnerText(nunitNode, nameof(DiscoveryMethod), Verbosity > 0), DiscoveryMethod.Current);
UseNUnitFilter = GetInnerTextAsBool(nunitNode, nameof(UseNUnitFilter), true);


// Engine settings
DiscoveryMethod = MapEnum(GetInnerText(nunitNode, nameof(DiscoveryMethod), Verbosity > 0), DiscoveryMethod.Current);
SkipNonTestAssemblies = GetInnerTextAsBool(nunitNode, nameof(SkipNonTestAssemblies), true);
AssemblySelectLimit = GetInnerTextAsInt(nunitNode, nameof(AssemblySelectLimit), 2000);


// Adapter Diagnostics
DumpXmlTestDiscovery = GetInnerTextAsBool(nunitNode, nameof(DumpXmlTestDiscovery), false);
DumpXmlTestResults = GetInnerTextAsBool(nunitNode, nameof(DumpXmlTestResults), false);
DumpVsInput = GetInnerTextAsBool(nunitNode, nameof(DumpVsInput), false);
FreakMode = GetInnerTextAsBool(nunitNode, nameof(FreakMode), false);
// End Diagnostics
ExtractNUnitDiagnosticSettings(nunitNode);

// Adapter Display Options
MapDisplayName(GetInnerText(nunitNode, nameof(DisplayName), Verbosity > 0));
FullnameSeparator = GetInnerText(nunitNode, nameof(FullnameSeparator), Verbosity > 0)?[0] ?? ':';

// EndDisplay



PreFilter = GetInnerTextAsBool(nunitNode, nameof(PreFilter), false);
MapTestCategory(GetInnerText(nunitNode, nameof(VsTestCategoryType), Verbosity > 0));
MapWarningTo = MapWarningOutcome(GetInnerText(nunitNode, nameof(MapWarningTo), Verbosity > 0));
Expand Down Expand Up @@ -399,19 +378,46 @@ public void Load(string settingsXml)

// Update NumberOfTestWorkers based on the DisableParallelization and NumberOfTestWorkers from runsettings.
UpdateNumberOfTestWorkers();
}

private void ExtractNUnitDiagnosticSettings(XmlNode nunitNode)
{
DumpXmlTestDiscovery = GetInnerTextAsBool(nunitNode, nameof(DumpXmlTestDiscovery), false);
DumpXmlTestResults = GetInnerTextAsBool(nunitNode, nameof(DumpXmlTestResults), false);
DumpVsInput = GetInnerTextAsBool(nunitNode, nameof(DumpVsInput), false);
FreakMode = GetInnerTextAsBool(nunitNode, nameof(FreakMode), false);
InternalTraceLevel = GetInnerTextWithLog(nunitNode, nameof(InternalTraceLevel), "Off", "Error", "Warning",
"Info", "Verbose", "Debug");
}

void UpdateTestProperties()
private void UpdateTestProperties(XmlDocument doc)
{
TestProperties = new Dictionary<string, string>();
foreach (XmlNode node in doc.SelectNodes("RunSettings/TestRunParameters/Parameter"))
{
foreach (XmlNode node in doc.SelectNodes("RunSettings/TestRunParameters/Parameter"))
{
var key = node.GetAttribute("name");
var value = node.GetAttribute("value");
if (key != null && value != null)
TestProperties.Add(key, value);
}
var key = node.GetAttribute("name");
var value = node.GetAttribute("value");
if (key != null && value != null)
TestProperties.Add(key, value);
}
}

private void ExtractRunConfiguration(XmlDocument doc)
{
var runConfiguration = doc.SelectSingleNode("RunSettings/RunConfiguration");
MaxCpuCount = GetInnerTextAsInt(runConfiguration, nameof(MaxCpuCount), -1);
ResultsDirectory = GetInnerTextWithLog(runConfiguration, nameof(ResultsDirectory));
TargetPlatform = GetInnerTextWithLog(runConfiguration, nameof(TargetPlatform));
TargetFrameworkVersion = GetInnerTextWithLog(runConfiguration, nameof(TargetFrameworkVersion));
TestAdapterPaths = GetInnerTextWithLog(runConfiguration, nameof(TestAdapterPaths));
CollectSourceInformation = GetInnerTextAsBool(runConfiguration, nameof(CollectSourceInformation), true);
DisableAppDomain = GetInnerTextAsBool(runConfiguration, nameof(DisableAppDomain), false);
DisableParallelization = GetInnerTextAsBool(runConfiguration, nameof(DisableParallelization), false);
DesignMode = GetInnerTextAsBool(runConfiguration, nameof(DesignMode), false);
CollectDataForEachTestSeparately =
GetInnerTextAsBool(runConfiguration, nameof(CollectDataForEachTestSeparately), false);
}

private void MapTestCategory(string vsTestCategoryType)
{
if (vsTestCategoryType == null)
Expand Down
6 changes: 3 additions & 3 deletions src/NUnitTestAdapter/CategoryList.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2014-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2014-2021 Charlie Poole, 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 @@ -55,9 +55,9 @@ public class CategoryList
// If it's not empty, it shows up as “Explicit [value]” in Test Explorer.
private const string ExplicitTraitValue = "";

private readonly NUnitProperty explicitTrait = new NUnitProperty(ExplicitTraitName, ExplicitTraitValue);
private readonly NUnitProperty explicitTrait = new (ExplicitTraitName, ExplicitTraitValue);

private readonly List<string> categorylist = new List<string>();
private readonly List<string> categorylist = new ();
private readonly TestCase testCase;
private readonly IAdapterSettings settings;
private readonly bool showInternalProperties;
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/EmbeddedAssemblyResolution.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2014-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2014-2021 Charlie Poole, 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
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/Metadata/TypeInfo.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2018-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2018-2021 Charlie Poole, 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
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/NUnit3TestDiscoverer.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2011-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2011-2021 Charlie Poole, 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
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/NUnit3TestExecutor.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2011-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2011-2021 Charlie Poole, 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
4 changes: 2 additions & 2 deletions src/NUnitTestAdapter/NUnitEngine/DiscoveryConverter.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2020-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2020-2021 Charlie Poole, 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 @@ -235,7 +235,7 @@ private static void ExtractAllFixtures(NUnitDiscoveryTestSuite parent, XElement

private static void ExtractTestFixtures(NUnitDiscoveryCanHaveTestFixture parent, XElement node)
{
foreach (var child in node.Elements())
foreach (var child in node.Elements().Where(o => o.Name != "properties"))
{
var type = child.Attribute(NUnitXmlAttributeNames.Type).Value;
var className = child.Attribute(NUnitXmlAttributeNames.Classname)?.Value;
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/NUnitEngine/DiscoveryException.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2020-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2020-2021 Charlie Poole, 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
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/NUnitEngine/Extensions.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2020-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2020-2021 Charlie Poole, 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
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2020-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2020-2021 Charlie Poole, 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
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/NUnitEngine/NUnitEngineAdapter.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2020-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2020-2021 Charlie Poole, 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
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/NUnitEngine/NUnitEventTestCase.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2020-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2020-2021 Charlie Poole, 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
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/NUnitEngine/NUnitResults.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2020-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2020-2021 Charlie Poole, 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
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/NUnitEngine/NUnitTestEvent.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2020-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2020-2021 Charlie Poole, 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
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/NUnitEngine/NUnitTestEventHeader.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2020-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2020-2021 Charlie Poole, 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
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2020-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2020-2021 Charlie Poole, 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
6 changes: 5 additions & 1 deletion src/NUnitTestAdapter/NUnitEngine/NUnitTestNode.cs
Expand Up @@ -9,6 +9,7 @@ public interface INUnitTestNode
string FullName { get; }
string Name { get; }
IEnumerable<NUnitProperty> Properties { get; }
string Seed { get; }
}

public abstract class NUnitTestNode : INUnitTestNode
Expand All @@ -17,10 +18,13 @@ public abstract class NUnitTestNode : INUnitTestNode
public virtual string Id => Node.GetAttribute("id");
public string FullName => Node.GetAttribute("fullname");
public string Name => Node.GetAttribute("name");

public bool IsNull => Node == null;

private readonly List<NUnitProperty> properties = new List<NUnitProperty>();
private readonly List<NUnitProperty> properties = new ();
public IEnumerable<NUnitProperty> Properties => properties;
public string Seed => Node.GetAttribute("seed");

protected NUnitTestNode(XmlNode node)
{
Node = node;
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/NUnitEventListener.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2011-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2011-2021 Charlie Poole, 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
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/NUnitTestAdapter.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2011-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2011-2021 Charlie Poole, 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
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/NUnitTestFilterBuilder.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2011-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2011-2021 Charlie Poole, 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
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/NavigationData.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2016-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2016-2021 Charlie Poole, 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
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/NavigationDataProvider.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2018-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2018-2021 Charlie Poole, 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
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/PackageSettings.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2014-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2014-2021 Charlie Poole, 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
4 changes: 2 additions & 2 deletions src/NUnitTestAdapter/Properties/AssemblyInfo.cs
@@ -1,5 +1,5 @@
// ****************************************************************
// Copyright (c) 2011-2020 Charlie Poole, Terje Sandstrom.
// Copyright (c) 2011-2021 Charlie Poole, Terje Sandstrom.
// ****************************************************************

using System;
Expand All @@ -12,7 +12,7 @@
[assembly: AssemblyDescription("A package containing the NUnit 3 TestAdapter for Visual Studio 2012 onwards. With this package you don't need to install the VSIX adapter package, and you don't need to upload the adapter to your Azure DevOps server.\r\n \r\nNote that this package ONLY contains the adapter, not the NUnit framework. You must also get the framework. You only need one such package for a solution. \r\n\r\nThe package works with Visual Studio 2012 and newer.\r\n")]
[assembly: AssemblyCompany("NUnit Project")]
[assembly: AssemblyProduct("NUnit3TestAdapter")]
[assembly: AssemblyCopyright("Copyright © 2011-2020 Charlie Poole, 2014-2020 Terje Sandstrom")]
[assembly: AssemblyCopyright("Copyright © 2011-2021 Charlie Poole, 2014-2021 Terje Sandstrom")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: CLSCompliant(false)]
Expand Down
11 changes: 11 additions & 0 deletions src/NUnitTestAdapter/Seed.cs
@@ -0,0 +1,11 @@
using Microsoft.VisualStudio.TestPlatform.ObjectModel;

namespace NUnit.VisualStudio.TestAdapter
{
public class Seed
{
internal static readonly TestProperty NUnitSeedProperty = TestProperty.Register(
"NUnit.Seed",
"Seed", typeof(string), TestPropertyAttributes.None, typeof(TestCase));
}
}
8 changes: 7 additions & 1 deletion src/NUnitTestAdapter/TestConverter.cs
@@ -1,5 +1,5 @@
// ***********************************************************************
// Copyright (c) 2011-2020 Charlie Poole, Terje Sandstrom
// Copyright (c) 2011-2021 Charlie Poole, 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 @@ -209,6 +209,7 @@ private TestCase MakeTestCaseFromDiscoveryNode(NUnitDiscoveryTestCase testNode)
}

testCase.AddTraitsFromTestNode(testNode, TraitsCache, _logger, adapterSettings);
testCase.SetPropertyValue(Seed.NUnitSeedProperty, testNode.Seed.ToString());

return testCase;

Expand Down Expand Up @@ -299,6 +300,11 @@ private VSTestResult GetBasicResult(INUnitTestEvent resultNode, IEnumerable<INUn
vsResult.Duration = TimeSpan.FromTicks(1);

vsResult.ComputerName = Environment.MachineName;
vsResult.SetPropertyValue(Seed.NUnitSeedProperty, resultNode.Seed);
if (adapterSettings.Verbosity >= 5)
{
vsResult.Messages.Add(new TestResultMessage(TestResultMessage.StandardOutCategory, $"seed: {resultNode.Seed}"));
}

FillResultFromOutputNodes(outputNodes, vsResult);

Expand Down