testfx icon indicating copy to clipboard operation
testfx copied to clipboard

Add `TestCategories` to `ITestDataRow`

Open Evangelink opened this issue 1 year ago • 3 comments

Update ITestDataRow to allow having a list of categories (let's name the property TestCategories).

For example, in here https://developercommunity.visualstudio.com/t/testcategory-and-datarow/465295 user is requesting for TestCategory to be applied on a given entry and not the full method.

Evangelink avatar Nov 20 '24 09:11 Evangelink

A possible workaround the users can make is something like this:

[TestMethod]
[Ignore] // Or TestCategory, etc..
[DataRow(data1)]
[DataRow(data2)]
public void TestMethodIgnored(...)
    => TestMethodCore(...);

[TestMethod]
[DataRow(data3)]
[DataRow(data4)]
public void TestMethod()
    => TestMethodCore(...);

private void TestMethodCore(...)
{
    // actual test logic.
}

Given that the workaround is easy, we need to evaluate whether we should be pushing users to that workaround, or if we really need to make a change. And what are the downsides for the workaround, is it going to be problematic in real scenarios? etc.

For example, one downside is if the user wants to have a combination of different things.

Let's say the user wants to have 4 DataRows with all possible combinations (i.e, ignored + TestCategory, not ignored + TestCategory, ignored + not TestCategory, not ignored + not TestCategory). This means there will be 4 test methods which is unfortunate and makes this workaround less usable. But how often does such scenario happen and whether it's worth doing a public API change for it.

Youssef1313 avatar Nov 20 '24 12:11 Youssef1313

This issue also overlaps with https://github.com/microsoft/testfx/issues/1411

Youssef1313 avatar Nov 20 '24 18:11 Youssef1313

@Youssef1313 I don't fully recall how much we have implemented but maybe this ticket is now stale.

Evangelink avatar Jun 17 '25 07:06 Evangelink