Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Parameterized NUnit tests run only once
rucamzu
#1 Posted : Friday, June 23, 2017 2:56:11 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/23/2017(UTC)
Posts: 2
Location: Ireland

Thanks: 3 times
Hi,

I'm using NCrunch 3.6.0.2 on a C# library project with NUnit 3.6.1, targeting .NET 4.5 on Visual Studio 2015. I'm writing parameterized tests like this:

Code:

[Test, TestCaseSource(nameof(SomeIntegers))]
public void MyTest(List<int> someIntegers)
{
    ...
}

private static IEnumerable<List<int>> SomeIntegers {get; }
    = new[]
        {
            new List<int>(1, 2, 3),
            new List<int>(4, 5, 6),
            new List<int>(7, 8, 9)
        };


In tests like the one above, NCrunch only runs the test once, with the first parameter (in this case new List<int>(1, 2, 3)). Both the NUnit console test runner and ReSharper handle this properly.

Am I missing some configuration?
Remco
#2 Posted : Friday, June 23, 2017 11:33:29 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 930 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi,

NCrunch should give you a warning about this with a link to the documentation page explaining this issue - http://www.ncrunch.net/documentation/considerations-and-constraints_unique-test-name.

To make this work under NCrunch, you need to use .SetName on each of the individual test case data elements (i.e. new List<int>(1, 2, 3).SetName("Test case 1"))
1 user thanked Remco for this useful post.
rucamzu on 6/27/2017(UTC)
rucamzu
#3 Posted : Monday, June 26, 2017 7:43:11 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/23/2017(UTC)
Posts: 2
Location: Ireland

Thanks: 3 times
Thanks for the help, I've been probably missing NCrunch warning. The link to the documentation is broken, but I'll try to get SetName working. Thanks!
Remco
#4 Posted : Monday, June 26, 2017 7:47:55 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 930 times
Was thanked: 1257 time(s) in 1170 post(s)
rucamzu;10689 wrote:
Thanks for the help, I've been probably missing NCrunch warning. The link to the documentation is broken, but I'll try to get SetName working. Thanks!


Can you confirm which link you're seeing as broken? Is this the one in the warning?
GreenMoose
#5 Posted : Monday, June 26, 2017 9:54:05 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 503

Thanks: 142 times
Was thanked: 66 time(s) in 64 post(s)
Remco;10687 wrote:
Hi,

NCrunch should give you a warning about this with a link to the documentation page explaining this issue - http://www.ncrunch.net/documentation/considerations-and-constraints_unique-test-name.
...


Remco;10690 wrote:

Can you confirm which link you're seeing as broken? Is this the one in the warning?


above link ( http://www.ncrunch.net/d...raints_unique-test-name ) returns
Quote:

Page Not Found
Sorry, but the documentation page you just tried to reference does not exist.
1 user thanked GreenMoose for this useful post.
rucamzu on 6/27/2017(UTC)
Remco
#6 Posted : Monday, June 26, 2017 10:09:28 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 930 times
Was thanked: 1257 time(s) in 1170 post(s)
It does indeed. Looks like the 's' was left off the end. Oops..

http://www.ncrunch.net/documentation/considerations-and-constraints_unique-test-names
1 user thanked Remco for this useful post.
rucamzu on 6/27/2017(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.059 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download