There doesn't seem to be any related post I can find here, at Nunit, or on MS sites that report any problems with the TestName parameter. Without this parameter, my tests are discovered and are run. But, if I add this parameter to any TestCase, then that specific test is not discovered, and the 'tests run' counter displays the reduced number. Then I remove the TestName parameter, and they are discovered and the test counter shows the expected number of test discovered.
Is this a known bug with VS2022? Or am I entering the values incorrectly?
- VS Enterprise 2022 v17.3.6
- .NET Framework v4.8.04084
- C# Tools 4.3.0-3.22470.13+80a8ce8d5fdb9ceda4101e2acb8e8eb7be4ebcea
- NuGet Package Manager 6.3.0
My tests all load and run as shown here, selecting parseAUR and clicking Run Tests, will then show four test discovered.
[TestCase(noneAur, ExpectedResult = 0, Description = "Finds nothing")]
[TestCase(oneAur, ExpectedResult = 1, Description = "Finds only one aur in report.")]
[TestCase(oneAurPlus, ExpectedResult = 1, Description = "Find one aur, ignores afr in report")]
[TestCase(twoAURs, ExpectedResult = 2, Description = "Finds two aur's in report")]
public int parseAUR(string source)
{
return ClaimStatusService.ProcessUndeliverableReport(source);
}
However, if I add TestName to the attribute list, then the tests are not discovered and are never run.
[TestCase(noneAur, ExpectedResult = 0, Description = "Finds nothing", TestName = "parseAUR(None)")]
[TestCase(oneAur, ExpectedResult = 1, Description = "Finds only one aur in report.", TestName = "parseAUR(One)")]
[TestCase(oneAurPlus, ExpectedResult = 1, Description = "Find one aur, ignores afr in report", TestName = "parseAUR(OnePlus)")]
[TestCase(twoAURs, ExpectedResult = 2, Description = "Finds two aur's in report", TestName = "parseAUR(Two)")]
Adding or removing TestName to any TestCase will alter that specific test's visibility in the TestExplorer and alters the discovered test count.
UPDATE: moving the TestName parameter from the end 'fixes' the issue. In fact, just moving one TestCase in this way cased all the TestCases to be discovered.