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

Notification

Icon
Error

Ignore tests using attributes
jgauffin
#1 Posted : Wednesday, September 18, 2013 5:55:10 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/6/2013(UTC)
Posts: 6
Location: Sweden

Thanks: 1 times
We are using [ExclusivelyUses] for some integration tests.

But for some tests I would like that NCrunch ignores them completely. Is that possible by using attributes? Something like [SkipTest]

Each dev is using their own NCrunch settings, so I can't do it in the configuration.
Remco
#2 Posted : Wednesday, September 18, 2013 9:31:42 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
Generally I'd recommend doing this by customising the engine modes in the solution with criteria that can exclude certain tests by category. You can then categorise the tests using the category attribute applicable to your test framework so that the exclusion criteria picks them up.

Engine modes are stored in the solution configuration file (.ncrunchsolution), which should usually be stored under source control and shared with all team members (see using NCrunch with source control for recommendations on which files to share with the team).

Of course, ignoring the tests via the Tests Window would also allow them to be shut off for NCrunch (again, this assumes you would share the NCrunch project configuration files using source control, which is highly recommended).

Another option is to use a compile condition so that NCrunch sees an ignore attribute adorning each of these tests when it builds them. For example, if you were using NUnit, the following would disable the test for NCrunch but not other test runners:

#if NCRUNCH
[Ignore]
#endif
[Test]
public void MyTest()
{
.. test code ..
}
moosey
#3 Posted : Monday, September 30, 2013 7:57:14 PM(UTC)
Rank: Member

Groups: Registered
Joined: 9/6/2011(UTC)
Posts: 12

Was thanked: 2 time(s) in 2 post(s)
Remco;4622 wrote:
Generally I'd recommend doing this by customising the engine modes in the solution with criteria that can exclude certain tests by category.


Hi Remco,

We've been doing exactly this. The only problem I've noticed is that if the ignored tests have previously failed, the "failed test count", as shown on the Risk/Progress Bar, still includes the tests that should have been ignored by the Engine Mode. I was expecting the count to show the number of failures for only those tests that are covered by the current Engine Mode.

Is this correct behaviour?
Remco
#5 Posted : Monday, September 30, 2013 11:13:36 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
Yes, this is the intended behaviour. A test ignored by the engine mode is still considered to be a test that could be run under different circumstances (i.e. manually). It may well be that if you want the tests to be gone and never looked at by NCrunch, using the Ignored Tests feature would probably be the best option.

Sorry, I realise my post above was potentially misleading when viewed in this context.
moosey
#6 Posted : Tuesday, October 1, 2013 8:29:26 AM(UTC)
Rank: Member

Groups: Registered
Joined: 9/6/2011(UTC)
Posts: 12

Was thanked: 2 time(s) in 2 post(s)
Seems reasonable, just wanted to check!

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