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

Notification

Icon
Error

When I add an NUnit Category to my TestFixtures these Fixtures disappear
Molibar
#1 Posted : Monday, January 12, 2015 7:55:26 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/12/2015(UTC)
Posts: 3
Location: United Kingdom

Thanks: 1 times
When I add an NUnit Category to my TestFixtures these Fixtures disappear from the NCrunch Test Window. I'm not using any weird characters, the category names I've used is "Facebook" and "SAM-16999".

Doesn't matter if I write it as:
[TestFixture, Category("Facebook")]
or separate them as :
[TestFixture]
[Category("Facebook")]

Same problem if I add the NUnit Categories to my Tests instead. This behaviour exists regardless of engine mode. Even when I create a custom engine mode allowing these categories.

I'm running VS2013 with NCrunch v2.10 (Released 18 Sep 2014).

Any idea about what might be wrong?

Regards,
Molibar
Remco
#2 Posted : Monday, January 12, 2015 10:02:56 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this issue.

Do the tests still appear to be detected by NCrunch? i.e. do you see code coverage for them, and the little arrow entry markers?

Do you notice any difference if you change the 'Framework utilisation type for NUnit' NCrunch solution-level configuration setting?

If you create an empty project/solution and add a new single NUnit test with a category to this project, do you experience the same behaviour? I'm wondering if this may be something specific to the solution you're working in, or something bigger and grander..


Cheers,

Remco
Molibar
#3 Posted : Tuesday, January 13, 2015 11:31:11 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/12/2015(UTC)
Posts: 3
Location: United Kingdom

Thanks: 1 times
Hi Remco,

Thanks for getting back to me so fast! I analyzed the problems a bit further and noticed that it has to do with if any of the Tests has Multiple Categories.

When the Test Fixture has Multiple Categories no tests will run for that fixture.
If the Test Fixture has One Category all tests without any Category will run.
If any of the Tests has a Category they won't be run if the Test Fixture has a Category.
If any of the Tests has Multiple Categories those Tests won't run.

This is consistent with my new Test Solution you asked me to create. Changing the Framework Utilization Type doesn't make the tests run, but depending on if I have UseStaticAnalysis or UseDynamicAnalysis the appearance is a bit different.

When selecting UseStaticAnalysis:
Tests with nested Categories won't run, won't be visible, and all the dots for the code rows of these tests will be black.

UseDynamicAnalysis:
Tests with nested Cagegories won't run, but will be visible but marked as failed and the first row of the test will have a red > on the top curly bracket. The rest of the dots for the code rows of these tests will be black.
The error of the failed tests will be:
"NCrunch: This test reported an inconclusive result. You can adjust whether NCrunch should treat this result as a pass by using the 'Consider inconclusive tests as passing' NCrunch project-level configuration setting. Category name must not contain ',', '!', '+' or '-'"

Are there a limit to the number of Categories one can have per test?


Regards,
Christer Brannstrom

Here's my Test Code if of interest:


using NUnit.Framework;

namespace NCrunch.Console
{
[TestFixture]
public class NCrunchTest
{
[Test]
// This test will run.
public void Test()
{
new UnitUnderTest().Wtf();
}

[Test, Category("Facebook")]
// This test will run.
public void TestWithCategory()
{
new UnitUnderTest().Wtf();
}

[Test, Category("Facebook"), Category("SAM-16999")]
// This test won't run due to its duplicate Categories.
public void TestWithTwoCategories()
{
new UnitUnderTest().Wtf();
}
}

[TestFixture, Category("Facebook")]
public class NCrunchTestWithCategory
{
[Test]
// This test will run.
public void Test()
{
new UnitUnderTest().Wtf();
}

[Test, Category("SAM-16999")]
// This test won't run due to the Category for the
// TestFixture in combination with its own Category.
public void TestWithCategory()
{
new UnitUnderTest().Wtf();
}
}

[TestFixture, Category("Facebook"), Category("SAM-16999")]
public class NCrunchTestWithTwoCategories
{
[Test]
// This test won't be run due to the duplicate Categories
// for the TestFixture.
public void Test()
{
new UnitUnderTest().Wtf();
}
}

public class UnitUnderTest
{
public string Wtf()
{
return "Hello!";
}
}
}

Remco
#4 Posted : Tuesday, January 13, 2015 9:49:06 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Christer,

Thanks for sharing these extra details. I can clearly see this happening when I run your test code.

NUnit appears to be 'throwing out' the tests during its discovery, as the categories contain illegal characters. Try removing the '-' from the SAM-16999 category to see if this makes any difference for you.

The error reporting from NCrunch is not ideal in this situation. I'd like to improve it, though this is deceptively difficult to do with the way the test discovery is designed.
1 user thanked Remco for this useful post.
Molibar on 1/14/2015(UTC)
Molibar
#5 Posted : Wednesday, January 14, 2015 11:58:05 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/12/2015(UTC)
Posts: 3
Location: United Kingdom

Thanks: 1 times
The amount of stupid I feel now, I thought I had tested that already.

Thanks a bundle, you're my hero!

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