Build/Test Issues

NCrunch + NUnitAttribute "TestCaseSource"

Started by GibSral on 2,836 views

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

Edited

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.

Post a reply

Log in to reply.