Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Tests/Common/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static int Main(string[] args)

if (!testCommandLine.ShouldShowHelp)
{
newArgs.AddRange(TestCommandLine.GetXunitArgsFromTestConfig(testCommandLine.TestConfigFile));
BeforeTestRun(newArgs);
}

Expand Down
33 changes: 33 additions & 0 deletions src/Tests/Microsoft.NET.TestFramework/TestCommandLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace Microsoft.NET.TestFramework
{
Expand All @@ -27,6 +28,8 @@ public class TestCommandLine

public string TestExecutionDirectory { get; set; }

public string TestConfigFile { get; private set; }

public bool ShowSdkInfo { get; private set; }

public static TestCommandLine Parse(string[] args)
Expand Down Expand Up @@ -70,6 +73,10 @@ public static TestCommandLine Parse(string[] args)
{
ret.TestExecutionDirectory = argStack.Pop();
}
else if (arg.Equals("-testConfigFile", StringComparison.CurrentCultureIgnoreCase))
{
ret.TestConfigFile = argStack.Pop();
}
else if (arg.Equals("-showSdkInfo", StringComparison.CurrentCultureIgnoreCase))
{
ret.ShowSdkInfo = true;
Expand Down Expand Up @@ -102,6 +109,32 @@ public static TestCommandLine Parse(string[] args)
return ret;
}

public static List<string> GetXunitArgsFromTestConfig(string testConfigFile)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dotnet test is not xunit specific tho

{
List<string> ret = new List<string>();
if (!string.IsNullOrEmpty(testConfigFile))
{
var testConfig = XDocument.Load(testConfigFile);
foreach (var item in testConfig.Root.Elements())
{
if (item.Name.LocalName.Equals("Method", StringComparison.OrdinalIgnoreCase))
{
var methodToSkip = item.Attribute("Name")?.Value;

if (!string.IsNullOrEmpty(methodToSkip) &&
bool.TryParse(item.Attribute("Skip").Value, out bool shouldSkip) &&
shouldSkip)
{
ret.Add("-nomethod");
ret.Add(methodToSkip);
}
}
}
}

return ret;
}

public static TestCommandLine HandleCommandLine(string [] args)
{
TestCommandLine commandLine = Parse(args);
Expand Down