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

Notification

Icon
Error

TestCaseSource
jrote1
#1 Posted : Friday, January 10, 2014 10:56:43 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/10/2014(UTC)
Posts: 2

When using the TestCaseSource attribute in nunit ncrunch does not always detect all the cases.

All the cases are detected with visual studio test runner.

And ideas or is this a bug?

Thank in advance
Remco
#2 Posted : Friday, January 10, 2014 11:05:31 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi, thanks for posting!

Check that the generated tests each have a unique name. If this is found to be the case, It'd be great to learn more about how these tests are structured (and named) for me to help identify whether there are problems involved with how NCrunch is handling them.


Cheers,

Remco
jrote1
#3 Posted : Friday, January 10, 2014 1:38:45 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/10/2014(UTC)
Posts: 2

this my code

namespace XMLDataExtractorTests
{
[TestFixture]
internal class XMLRetrieverTests
{
public static List<object[]> _metricCases = new List<Object[]>
{
new object[]
{
TestUtilities.Metrics[ 0 ], ApplicationMetricsFile, ApplicationMetricsSql
},
new object[]
{
TestUtilities.Metrics[ 1 ], RuleResultFile, CodeRuleResultSql
},
new object[]
{
TestUtilities.Metrics[ 2 ], RuleResultFile, CodeRuleResultSql
},
new object[]
{
TestUtilities.Metrics[ 3 ], RuleResultFile, CodeRuleResultSql
},
new object[]
{
TestUtilities.Metrics[ 4 ], RuleResultFile, CodeRuleResultSql
},
new object[]
{
TestUtilities.Metrics[ 5 ], RuleResultFile, CodeRuleResultSql
},
new object[]
{
TestUtilities.Metrics[ 6 ], RuleResultFile, CodeRuleResultSql
},
new object[]
{
TestUtilities.Metrics[ 7 ], RuleResultFile, CodeRuleResultSql
}
};

[TestCaseSource( "_metricCases")]
public void GetXmlDocument_GivenMetric_ReturnsXDocumentContainingMetric( Metric metric, string filePath, string sql )
{
......
}

[TestCaseSource( "_metricCases" )]
public void GetXmlDocument_GivenMetric_CallsCorrectMethodWithCorrectSqlInSqlHelperWrapper( Metric metric, string filePath, string sql )
{
....
}
}
}

so it only runs the first few test cases but using the visual studio test runner it works fine.

Thanks in advance
Remco
#4 Posted : Friday, January 10, 2014 11:32:03 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi, thanks for sharing the code. Something I just thought I'd check with you here is whether the .ToString() method on the Metric class returns a unique value for each Metric object.

For NCrunch this is particularly important, as TestCaseSource relies on .ToString() to generate the name of each test it returns. NCrunch relies on each test having a unique name in order for the test to be correctly identified through the engine.

I noticed when testing this code that when I didn't override the .ToString() method on the Metric class and provide something unique, NCrunch would only run 2 tests per TestCaseSource attribute, where it should normally be running 8.

Does this solve the issue for you?


Cheers,

Remco
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.167 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download