-
Notifications
You must be signed in to change notification settings - Fork 746
Enable setting IgnoreUntilDate in TestCaseData.Ignore #3275
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
Comments
I don't see any problem with adding this functionality to |
Sorry not to have brought this up sooner, but I was on the road. Let's say we go with this API. In that case, a user can ignore a test case until a certain date... using [Test, Ignore("Some reason", Until="1942-10-12")] using static TestCaseData[] MyData {
new TestCaseData(arg1, arg2).Ignore("Some Reason", "1942-10-12")
};
[TestCaseSource("MyData")] using [TestCase(arg1, arg2, Ignore="Some reason")] // No way to specify until So, I think that if we implement Until for TestCaseSource we should also do it for TestCase, either now or in the near future. For consistency, we should pick a similar approach in all three. The proposed method for If we did this for [TestCase(arg1, arg2, Ignore="Some reason", Until="1942-10-12")] Therefore, I'd like to make the static TestCaseData[] MyData {
new TestCaseData(arg1, arg2).Ignore("Some Reason").Until("1942-10-12")
};
[TestCaseSource("MyData")] NOTE: for both |
I agree that there can improvements to the API. Considering the suggestion made by @rprouse on the pull request and your comment here, I think a fluent API makes more sense than the current implementation. My concept for this API would be something along these lines - borrowing from your example:
As for adding the API to the
I'm interested in hearing other suggestions and retooling my implementation. |
As NUnit is updated to current standards, it would seem that DateTime should be updated to DateTimeOffset wherever possible. DateTime is considered obsolete, and is fraught with issues. Maybe there should even be a PR to update all of NUnit to DateTimeOffset? |
@abborg Your approach sounds great. I think we have often done this by using a nested public class to avoid cluttering the namespace. It can be made non-browsable soit doesn't show up in intellisense. |
@oznetmaster We can update our internals, of course, but it's not up to us to update users! We would have to maintain both options in public APIs. |
A desirable goal is to get people to convert to DateTimeOffset, since it remove the ambiguity, and issues, of DateTime. Since there is an implicit conversion from DateTime to DateTimeOffset, it should be fully compatible to use DateTimeOffset as parameters in new API's, and even to update old API's to use it in their parameters. API's which return DateTime values are more difficult, but I cannot think of any offhand? Are there any? |
I agree that it's a desirable goal for most projects, but since they are not my projects, it's really not my business. If we were Microsoft, we might have some standing to tell people how to use .NET and C#, but we aren't, and I don't think this is a role we want to get into. Of course, if there is a non-breaking way to change our APIs, we can do that. Maybe an issue along these lines should be filed. |
That was all that I was suggesting. It appears that DateTimeOffset can be used in a non-breaking way to update our API's. I was also asking if it warranted an issue/PR to do so. It would certainly seem that any new API should use DateTimeOffset exclusively rather then DateTime. |
@abborg I like your proposal. It fits nicely with our current fluent syntax. @oznetmaster I actually originally wrote |
That said, since there is an explicit conversion for |
And implicit as well. |
Looks good to me. Is there a way to signal to Andrew that we've reached a consensus and are ready for him to go ahead? |
@abborg are you following this? |
Yes, I've been following this. I'll begin implementing based on the earlier discussion. It may take me a bit of time to finish implementing the changes as I'm busy with other work for the next week, but I should hopefully have something for review within the next two weeks. |
Currently, there is no easy method to set an
IgnoreUntilDate
property on a test case when usingTestCaseData
. Similar to the optionalUntil
property on theIgnoreAttribute
, an overload of theIgnore(string)
method can be added to that takes in a reason string as well as an until date as a string. The signature would be something along the lines of:Here's an example usage
The text was updated successfully, but these errors were encountered: