lundi 30 septembre 2019

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

Aucun commentaire:

Enregistrer un commentaire