-
Notifications
You must be signed in to change notification settings - Fork 259
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
RFC: Ignore/Skip test or test case #1411
Comments
Personal comment here, I like that it is a specific attribute: when i do a code review, I do not see a modify attribute change but a attribute being remove or added which is simple to review - full line added or remote, less change of merge conflict ? So potentially for a data driven method, do you prefer one attribute for all, or one attribute per ignore ? Extra requests, could we have created our own ignore attribute ? For example, in our case, we would like the developer to give 2 informations, one being the work item to address the ignore command , the second the message so we would like to have our own attribute like [MyProjectIgnore(1234, "message")] but as the attribute is sealed, we cannot really do anything :( |
Hi @fforjan, thanks for the valuable feedback! |
One more drawback is that the new approach would make it different from other attributes that provide metadata or configure execution like TestCategory, Owner, Timeout. |
RFC: Ignore/Skip test or test case
- [ ] Approved in principleSummary
Improve test/test case skipping mechanism.
Motivation
Today, it is possible to use IgnoreAttribute, that can be set on a method or on a class to allow ignoring respectively a test method or all test methods of a given class.
There are multiple design issues with this solution:
It is possible to set it on any class or method even if they are not a test class or test method. When set in some invalid location, the attribute will have no effect so the impact on user is limited but this is providing a bad user experience. This can also be confusion for users in contexts such as initialization or cleanup methods (
[AssemblyInitialize]
,[ClassInitialize]
,[TestInitialize]
,[AssemblyCleanup]
,[ClassCleanup]
,[TestCleanup]
) where it might be thought this would ignore the marked initialize/cleanup method.It is not possible to ignore only specific entries of parameterized tests. For example, it's currently impossible to ignore a
DataRow
entry (see How to ignore particular test case (DataRow) #1043).Detailed design
We would like to obsolete the existing attribute and replace it with some property (e.g.
Ignore = "some reason"
) on the various attributes where we want to support this feature.By doing so, we ease discoverability as the property is available on the attribute we have already defined and we would fix the design issues raised above.
We would keep the multi-level support:
If a test class is marked as ignored (e.g.
[TestClass(Ignore = "...")]
) then all test methods are ignored.If a data test method is marked as ignored (e.g.
[DataTestMethod(Ignore = "...")]
) then all test cases are ignored.To complete furthermore this feature, we may also want to introduce some new concepts for other data sources:
Another property like
IgnoreRows
that would allow to specific a list of rows to skip with either only 1 message or a list of messages (e.g.[DynamicData(IgnoreRows = ([0, 2, 3], "message"))]
or[DynamicData(IgnoreRowIndexes = [(0, "message 1"), (2, "message 2"), (3, "message 3")])]
).Replace (or add) the
object[]
part ofIEnumerable<object[]>
by some specific type (we could reuseDataRow
or introduce some new type) that would allow to skip the entry for all tests using this source.Drawbacks
Users would need to update their tests to use the new syntax if we obsolete the old one.
Alternatives
We could extend current
[Ignore]
attribute to provide properties for rows to ignore.There aren't lot of requests/complaints about the discoverability or the fact this is not possible to suppress a specific row/entry of a parameterized test.
Compatibility
Not per se but the goal is to drop the older solution.
Unresolved questions
None.
The text was updated successfully, but these errors were encountered: