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

Add OS related attribute #4700

Open
Evangelink opened this issue Jan 17, 2025 · 2 comments
Open

Add OS related attribute #4700

Evangelink opened this issue Jan 17, 2025 · 2 comments

Comments

@Evangelink
Copy link
Member

Summary

Add a new attribute that will skip running the test if the OS doesn't match.

Background and Motivation

There are many implementation of OS skip attributes in other test framework but none in MSTest. We should close the gap here.

Looking at people implementation, there are 2 main trends, an inclusive attribute like SupportedOS and an exclusive attribute like IgnoreOnOS. Both of these ways have cons when you want to have all but one (few) in which case the other attribute would be better.

Proposed Feature

I would like to have our implementation allowing to choose between "include" and "exclude" mode (with most likely "include" as default behavior).
The attribute name could be:

  • ConditionalOSAttribute
  • OSConditionAttribute
  • OSFilterAttribute

I think a naming like Condition, Conditional or Filter would give us more flexibility to introduce more features alike (e.g. conditional run based on architecture, based on locale, based on env var...)

Alternative Designs

We could also ship 2 specific attributes

  • SupportedOSAttribute
  • UnsupportedOSAttribute
@Youssef1313
Copy link
Member

Maybe we can even abstract it more? Like:

public abstract class ConditionalAttribute : Attribute
{
    public abstract string IgnoreMessage { get; }
    public abstract bool ShouldIgnore { get; }
}

public sealed class ConditionalOSAttribute : ConditionalAttribute
{
    // ...
}

@Evangelink
Copy link
Member Author

I quite like it as it's making it more general for the ignore at data source level and on the DataRow item we will create.

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

No branches or pull requests

2 participants