-
Notifications
You must be signed in to change notification settings - Fork 157
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
NUnit question/ request? #637
Comments
I'm fairly certain that the xUnit.net Have you tried that? |
I have not used XUnit (we use NUnit) but I think I read somewhere that xUnit and NUnit behaves different with the Property attribute so you are properly right. |
In the NUnit C# example in FSCheck repo, I noticed a comment saying that what I want for a "Simple boolean Function" but it says nothing about two-argument functions like this one. |
Where is that "compile error" coming from? csc doesn't know about FsCheck, or test methods. Is this the NUnit equivalent of #636? |
It apparently comes from NUnit - The error message also mentions NUnit1027 which is described here "https://docs.nunit.org/articles/nunit-analyzers/NUnit1027.html" I have tried to disable the error using "#pragma warning disable NUnit1027" but this just give another error "No test is available in xxxxx. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again" I also tried to add an extra attribute [TestCase(0,0, ExpectedResult = true)] below [Property] which compiles but then the Property attribute is ignored. So not good either. Maybe the implementation of the [Property] attribute defined by FsCheck should be changed to something simar to [TestCase] but with the right behavior of cause ??? |
If the issue is with an NUnit analyser, it might be a bug in the analyser. We recently had a similar issue with the xUnit.net analyser, and the xUnit.net maintainers accepted it as a bug at their end. I'm not familiar with the NUnit implementation or extensibility model, but perhaps it might be appropriate to follow such a line of inquiry. |
I don't think NUnit will consider it a bug on their part - I think it is the FsCheck Property attribute that done wrong. |
Why not? |
Because (my Guess) from NUnits point of view it thinks of FsCheck's [Property] as similar to the [Test] attribute where this behavior is wrong. If FsCheck changes it's implementation to be similar to NUnit's [TestCase] attribute there would be no problem. Hence, they will properly say that FsCheck coded its [Property] attribute wrong. |
FsCheck’s Property is only superficially similar to TestCase. It is not possible to do what you suggest. The NUnit analyser is clearly too eager here. Turn it off and/or check in with the NUnit people so they can fix it. |
I have tried to disable the particular error in the Nunit analyser but than the (Property) test compiles but is not executed. |
Yes, I can reproduce that, but if I add When a framework like xUnit.net or NUnit exposes extensibility points, it's to be expected that third parties take advantage of these - sometime in unexpected ways. Here, FsCheck is the third party. When the good xUnit.net people changed their analyser rule, they seem to have forgotten to take third party extensibility into account (which is understandable), but as soon as we told them, they immediately realised that they'd been 'too eager', as @kurtschelfthout put it. It still sounds to me as though something similar is going on here. |
See also Issue 623: #623 |
Closing as dupe |
I am experimenting with FsCheck using C# and NUnit as shown below in the code. I wonder why properties MUST be declared with a verbose syntax as in method 'ThisWorks' while the much simpler version 'ThisShouldAlsoWorkButItWontCompile' gives a compilation related to the FsCheck Property attribute error saying: "The test method has '2' parameter(s), but only '0' argument(s) are supplied by attributes."
It should be possible to transform the latter function into the first one automatically by FsCheck. It would result in much more readable/maintainable/portable tests. Why not?
The text was updated successfully, but these errors were encountered: