Skip to content

Commit

Permalink
Issue912 (#925)
Browse files Browse the repository at this point in the history
* Updated comments in NUnitTestFilterBuilder

* fixes

* updated for 912 and 919

* remove debugflag
  • Loading branch information
OsirisTerje authored Dec 11, 2021
1 parent 3be32d6 commit 4d47546
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 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.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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 4d47546

Please sign in to comment.