Parameterized tests with TestCaseSource attribute not working
See original GitHub issueDescription
I want to run parameterized test using the NUnit attribute TestCaseSource
. Please tell me how to do that and add code examples for paremterized tests to the documentation on https://fsprojects.github.io/FsUnit/NUnit.html.
Repro steps
Run the code snippet
namespace FooSpace
module FooTests =
open NUnit.Framework
open FsUnit
let mySrc1 = [|
(17, "One", 1.5);
(42, "Two", 2.3);
|]
let mySrc2 = [|
[| (17, "One", 1.5) |];
[| (42, "Two", 2.3) |];
|]
let mySrc3 = seq {
yield (17, "One", 1.5)
yield (42, "Two", 2.3)
}
[<Test>]
[<TestCaseSource("mySrc1")>]
let testFoo (testData: int * string * float) =
let foo, bar, umu = testData
1 |> should equal 1
Note that I tried different flavours of test case sources above, based on (rather old) search results from the web like, e.g.
- https://stackoverflow.com/a/35733745/3760986
- http://hombredequeso.id.au/2014/06/20/fsunit-data-driven-tests.html
- https://winterlimelight.com/2016/12/20/fsunit/
- http://andy-p.github.io/FsTestCaseSource.html
Expected behavior
A dotnet test
discovers two test cases, both are run and succeed.
Actual behavior
Two test cases are discovered and run, but both fail with the error message
Not enough arguments provided, provide at least 3 arguments.
Exception doesn't have a stacktrace
no matter if one uses mySrc1
, mySrc2
or mySrc3
.
Known workarounds
None.
Related information
- Windows 8.1
- FsUnit Release 3.8.0
- .NET Core 3.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
c# - nunit-console does not run tests parameterized with ...
Trying to run Nunit tests parameterized with TestCase attribute. Something like this: [TestFixture] public class MyClass { [Test] ...
Read more >NUnit Tutorial: Parameterized Tests With Examples
In this guide, we will showcase NUnit parameterized test cases along with the commonly used attributes like the TestFixture NUnit attribute.
Read more >TestCaseSource
TestCaseSource. TestCaseSourceAttribute is used on a parameterized test method to identify the source from which the required arguments will be provided.
Read more >NUnit Tests Using "TestCaseSource" Not Correctly ...
NUnit has an attribute that allows a test to get parameterized data from a source method - the TestCaseSourceAttribute.
Read more >How to write Nunit Parameterized Test
In this technique, Nunit uses the TestCase attribute to pass the various data sets at Test level. This technique is helpful when we...
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
Okay. Well. Thanks for your help anyway. I’m closing this issue.
Ah, sorry. My fault. I only now saw the
member
keyword. I got it. The class is necessary. Let me try…