Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows to have metadata applied to specific entries of parameterized tests #4089

Open
Evangelink opened this issue Nov 20, 2024 · 2 comments

Comments

@Evangelink
Copy link
Member

Summary

We have received a couple of requests internally and externally from users about the ability to have some of the attributes working for specific entries of parameterized tests.

Background and Motivation

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.

Here #1043 the user is asking for the Ignore attribute to work on specific row.

Proposed Feature

Attributes cannot work on attributes so the only possibility I see is to have properties/options on the attribute. I would suggest to do the same for TestMethod to have similar behavior.

More thoughts need to be put onto designing this request but I wanted to capture the global idea.

Alternative Designs

@Youssef1313
Copy link
Member

Youssef1313 commented Nov 20, 2024

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
Copy link
Member

This issue also overlaps with #1411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants