J.Kirk.
J.Kirk.

Reputation: 973

Nunit TestCaseSource with setName also shows original test in testexplorer

I'm attempting to use TestCaseSource to re-use the test with different data. Here I'm trying to give my tests their own name with the 'setName' property which works fine. My issue is that the original test also shows up in the testexplorer. It doesn't seem possible to run. How can I get rid of it in the test explorer?

Simple reproduction:

[TestFixture]
public class Tests
{
    [TestCaseSource(nameof(MyTestData))]
    [Category(name: "MyCategory")]
    public void OriginalTest(string first, string second)
    {
        Assert.IsTrue(true);
    }

    private static IEnumerable<TestCaseData> MyTestData
    {
        get
        {
            yield return new TestCaseData("firstString", "secondString").SetName("FirstTest");
            yield return new TestCaseData("firstString", "secondString").SetName("SecondTest");
        }
    }
}

My test explorer looks like this

enter image description here

Upvotes: 4

Views: 2269

Answers (1)

Felipe Coelho
Felipe Coelho

Reputation: 26

This seemed to be a problem with the adapter.

I was having this same issue, using SetArgDisplayNames instead, which, while not providing the expected visual result, was the best fit for this kind of usage until the problem was fixed.

Updating NUnit3TestAdapter to v3.16.0 the problem no longer occurred:

VS Test Adapter example

Upvotes: 1

Related Questions