nUnit - Ignoring a single inline TestCase

393 Views Asked by At

I'm using nUnit for some testing and I have a test with multiple inline test case inputs. I have a known bug with one of the TestCase inputs, and I would like to have that single TestCase ignored, but the other four run. When I tried

TestCase["ears"]
TestCase["eyes", Ignore("Bug is JIRA #FOO", Until = "2022-02-15"))]
TestCase["nose"]
TestCase["mouth"]
TestCase["touch"]
public async Task CanUseSense(string sense)
{
    useSense(sense);
}

What I expected was that I would get four of the five test cases run, and one ignored, but instead I see all five test cases ignored. Are each of the test cases not an individual instance of an attribute, or are they treated as a single attribute containing all the test cases? nunit docs

1

There are 1 best solutions below

1
On BEST ANSWER

In your sample you applied the IgnoreAttribute. What you want to do, is to set the Ignore property of the TestCaseAttribute.

[TestCase("ears")]
[TestCase("eyes", Ignore = "Bug is JIRA #FOO", Until = "2022-02-15")]
[TestCase("nose")]
[TestCase("mouth")]
[TestCase("touch")]
public async Task CanUseSense(string sense)
{
    Assert.That(sense, Is.Not.EqualTo("eyes"));
}