NUnit question/ request?
See original GitHub issueI 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?
public class NUnitTests
{
private int Add(int x, int y) // Method under test
{
return x + y;
}
[Property(Verbose = false, MaxTest = 200)]
public Property ThisWorks()
{
Func<int,int,bool> summer = (a,b) => Add(a,b) == a + b;
return Prop.ForAll(summer);
}
[Property(Verbose = false, MaxTest = 200)]
public bool ThisShouldAlsoWorkButItWontCompile(int x, int y)
{
return Add(x,y) == x+y;
}
}
Issue Analytics
- State:
- Created 2 months ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
Top 20 NUnit Interview Questions and Answers 2023
This article is focused on frequently asked NUnit Interview Questions that cover NUnit's Core features, Attributes, installation, and many more.
Read more >How do I Test Controller HTTP Methods with Nunit test?
This is an integration test because you're actually making HTTP requests. The advantage is you are also testing the actual service ...
Read more >Top 40 NUnit Interview Questions: To Crack Your Next ...
Prepare to ace your NUnit interviews questions with our thorough set of solutions that ... Here are some NUnit assertion method examples:.
Read more >How to mock the Request.form for only a few values on ...
I am new to Nunit and Moq framework and am totally stuck in testing for one of my controller as it fetches some...
Read more >NUnit With C#
NUnit is a unit-testing framework for .NET applications in which the entire application is isolated into diverse modules.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Closing as dupe