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

Issue912 #925

Merged
merged 5 commits into from Dec 11, 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
2 changes: 1 addition & 1 deletion build.cake
Expand Up @@ -13,7 +13,7 @@ var configuration = Argument("configuration", "Release");
//////////////////////////////////////////////////////////////////////

var version = "4.2.0";
var modifier = "-alpha.201";
var modifier = "-alpha.919.3";

var dbgSuffix = configuration.ToLower() == "debug" ? "-dbg" : "";
var packageVersion = version + modifier + dbgSuffix;
Expand Down
5 changes: 1 addition & 4 deletions src/NUnitTestAdapter/NUnit3TestExecutor.cs
Expand Up @@ -119,10 +119,7 @@ public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrame
var vsTestFilter = VsTestFilterFactory.CreateVsTestFilter(Settings, runContext);
filter = builder.ConvertVsTestFilterToNUnitFilter(vsTestFilter);
}
if (filter == null)
{
filter = builder.FilterByWhere(Settings.Where);
}
filter ??= builder.FilterByWhere(Settings.Where);

foreach (string assemblyName in sources)
{
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitTestAdapter/NUnitEngine/DiscoveryConverter.cs
Expand Up @@ -170,7 +170,7 @@ public IList<TestCase> Convert(NUnitResults discoveryResults, string assemblyPat
return loadedTestCases;

IEnumerable<NUnitDiscoveryTestCase> RunnableTestCases(bool isExplicit) =>
isExplicit || !Settings.DesignMode
isExplicit
? TestRun.TestAssembly.AllTestCases
: TestRun.TestAssembly.RunnableTestCases;
}
Expand Down
6 changes: 6 additions & 0 deletions src/NUnitTestAdapter/NUnitTestFilterBuilder.cs
Expand Up @@ -65,6 +65,9 @@ public TestFilter ConvertVsTestFilterToNUnitFilter(IVsTestFilter vsFilter, IDisc
return result;
}

/// <summary>
/// Used when running from command line, mode Non-Ide, e.g. 'dotnet test --filter xxxxx'. Reads the TfsTestCaseFilterExpression.
/// </summary>
public TestFilter ConvertVsTestFilterToNUnitFilter(IVsTestFilter vsFilter)
{
if (string.IsNullOrEmpty(vsFilter?.TfsTestCaseFilterExpression?.TestCaseFilterValue))
Expand All @@ -87,6 +90,9 @@ public TestFilter ConvertTfsFilterToNUnitFilter(IVsTestFilter vsFilter, IDiscove
return testCases.Any() ? FilterByList(testCases) : NoTestsFound;
}

/// <summary>
/// Used when a Where statement is added as a runsettings parameter, either in a runsettings file or on the command line from dotnet using the '-- NUnit.Where .....' statement.
/// </summary>
public TestFilter FilterByWhere(string where)
{
if (string.IsNullOrEmpty(where))
Expand Down
10 changes: 5 additions & 5 deletions src/NUnitTestAdapterTests/TestExecutionTests.cs
Expand Up @@ -82,11 +82,11 @@ public void LoadMockassembly()
[TestCase("method =~ MockTest?", 5)]
[TestCase("method =~ MockTest? and cat != MockCategory", 3)]
[TestCase("namespace == ThisNamespaceDoesNotExist", 0)]
[TestCase("test==NUnit.Tests.Assemblies.MockTestFixture", MockTestFixture.Tests, TestName = "{m}_MockTestFixture")]
[TestCase("test==NUnit.Tests.Assemblies.MockTestFixture", MockTestFixture.Tests - MockTestFixture.Explicit, TestName = "{m}_MockTestFixture")]
[TestCase("test==NUnit.Tests.IgnoredFixture and method == Test2", 1, TestName = "{m}_IgnoredFixture")]
[TestCase("class==NUnit.Tests.Assemblies.MockTestFixture", MockTestFixture.Tests)]
[TestCase("name==MockTestFixture", MockTestFixture.Tests + NUnit.Tests.TestAssembly.MockTestFixture.Tests)]
[TestCase("cat==FixtureCategory", MockTestFixture.Tests)]
[TestCase("class==NUnit.Tests.Assemblies.MockTestFixture", MockTestFixture.Tests - MockTestFixture.Explicit)]
[TestCase("name==MockTestFixture", MockTestFixture.Tests + NUnit.Tests.TestAssembly.MockTestFixture.Tests - MockTestFixture.Explicit)]
[TestCase("cat==FixtureCategory", MockTestFixture.Tests - MockTestFixture.Explicit)]
public void TestsWhereShouldFilter(string filter, int expectedCount)
{
// Create a fake environment.
Expand Down Expand Up @@ -158,7 +158,7 @@ public void CorrectNumberOfTestCasesWereStarted()
Console.WriteLine(ev.TestCase.DisplayName);
Assert.That(
testLog.Events.FindAll(e => e.EventType == eventType).Count,
Is.EqualTo(MockAssembly.ResultCount - BadFixture.Tests - IgnoredFixture.Tests - ExplicitFixture.Tests));
Is.EqualTo(MockAssembly.ResultCount - BadFixture.Tests - IgnoredFixture.Tests - ExplicitFixture.Tests - MockTestFixture.Explicit));
}

[Test]
Expand Down
Expand Up @@ -173,7 +173,7 @@ public void TestParser(string input, string output)
{
Assert.That(_parser.Parse(input), Is.EqualTo($"<filter>{output}</filter>"));

XmlDocument doc = new XmlDocument();
XmlDocument doc = new ();
Assert.DoesNotThrow(() => doc.LoadXml(output));
}

Expand Down