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

Notification

Icon
Error

NCrunch + NUnitAttribute "TestCaseSource"
GibSral
#1 Posted : Monday, March 16, 2015 12:50:11 PM(UTC)
Rank: Member

Groups: Registered
Joined: 12/1/2014(UTC)
Posts: 27
Location: Germany

Thanks: 3 times
Was thanked: 3 time(s) in 3 post(s)
Hi,

i have an Issue concering NUnit-Tests decorated with the TestCaseSource-Attribute.
NCrunch only shows me 1 test but in fact there are more because my TestCaseSource returns multiple Testcases.
The Resharper-testrunner shows me all testcases returned by the source.
This makes debugging a specific testcase very difficult because the whole test failes.

Any solutions to this would be very much appreciated.

Thanks in advance
Lars


party solved the issue:
changed from
public void GetAlarms_WithAlarmDataSetsProvided_ReturnsCollectionOfAlarmsWithCorrectTimeSpan(List<GetAlarmDataList> alarmDataSets, List<Alarm> expectedAlarms)
to
public void GetAlarms_WithAlarmDataSetsProvided_ReturnsCollectionOfAlarmsWithCorrectTimeSpan(string testCase, List<GetAlarmDataList> alarmDataSets, List<Alarm> expectedAlarms)

and altered the TestCaseSource to insert the TestCase as string as parameter of the TestCaseData

private static TestCaseData MakeSingleAlarmWithNoDurationTestCase()
{
var legacyAlarmsDataSets = new List<GetAlarmDataList>
{
new GetAlarmDataList { AlarmTime = 3.January(2015).At(12, 30), BatteryLow = true }
};

var expectedAlarms = new List<Alarm>
{
new Alarm { AlarmTime = 3.January(2015).At(12, 30), AlarmTimeSpan = new TimeSpan(0), Key = "BatteryLow" }
};

return new TestCaseData("SingleAlarmWithNoDuration", legacyAlarmsDataSets, expectedAlarms);
}

Now all TestCases are visible as seperate Tests
Remco
#2 Posted : Monday, March 16, 2015 9:33:31 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,000

Thanks: 932 times
Was thanked: 1259 time(s) in 1172 post(s)
Hi,

This is caused by a limitation in which tests identified by TestCaseSource need to have unique names when represented to NCrunch. Because the tests being generated in this instance have no way for NCrunch to tell them apart, it bundles them together.

It is unfortunately impossible to fix this in NCrunch. NUnit has an ID system but the IDs shift depending upon the other tests in the suite, making this unusable for NCrunch. When using TestCaseSource, you'll need to make sure the tests are named differently either by using different identifiable parameters or by specifying their names.
1 user thanked Remco for this useful post.
GibSral on 3/17/2015(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.029 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download