testfx icon indicating copy to clipboard operation
testfx copied to clipboard

Provide a way to specify the test name for a data row test

Open stecydube opened this issue 6 years ago • 3 comments

Description

Currently, MSTest V2 constructs the name of the test using the specified parameters and this can be very long for some scenario and also not intention revealing about the actual sub test being performed.

It would be better to have a way to specify the name for a test.

Steps to reproduce

Expected behavior

DataRow(1,2,3,TestName="Sequential numbers") DataRow(2,4,6,TestName="Even numbers")

should display Test Passed - Sequential numbers Test Passed - Even numbers

Actual behavior

DataRow(1,2,3) DataRow(2,4,6)

Test Passed - TestSomeNumbers (1,2,3) Test Passed - TestSomeNumbers (2,4,6)

Environment

MSTest V2

stecydube avatar Jun 26 '18 14:06 stecydube

@stecydube : There is indeed a way to specify testname for a datarow test. You can try something like:

        [TestMethod]
        [DataRow(1,2,3, DisplayName ="Sequential numbers")]
        public void TestSomeNumbers (int x, int y, int z)
        {
            Assert.IsTrue(true);
        }

jayaranigarg avatar Jun 27 '18 09:06 jayaranigarg

@pvlakshm : Can we add some examples for datarow attribute in documentation here to prevent such issues in future?

jayaranigarg avatar Jun 27 '18 09:06 jayaranigarg

Great, thank you!

stecydube avatar Jun 27 '18 12:06 stecydube

I will mark this as fixed because the property is listed in the official API doc: https://learn.microsoft.com/dotnet/api/microsoft.visualstudio.testtools.unittesting.datarowattribute.displayname

Evangelink avatar Nov 23 '22 22:11 Evangelink