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

Notification

Icon
Error

Using custom trait via Xunit
interhan
#1 Posted : Monday, February 3, 2014 7:40:12 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/13/2012(UTC)
Posts: 6
Location: Seoul

Thanks: 1 times
Hi,

in case of default Trait, i.e
[Fact, Trait("Category","Test")]

I could see NCrunch filters out with given Trait name as category well. From that, I tried to this

public class CustomTraitAttribute : TraitAttribute
{
const string DefaultName = "DefaultCategory")
CustomTraitAttribute(string value) : base (DefaultName,value) {}
}

then mark it
[Fact, CustomTrait("Test")]

and now NCrunch does not filters out via trait name, also it automatically skips test and can't lookup in test cases list.

Is there any specific configuration required to make those custom trait as same as default trait attribute?

Thanks in advance.
Remco
#2 Posted : Monday, February 3, 2014 11:05:24 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,980

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thanks for sharing this issue.

NCrunch does support custom trait attributes, but only if the Framework Utilisation Type for XUnit/Gallio is set to 'DynamicAnalysis'.

The reason for this is that NCrunch needs to execute your run-time code in order to resolve the custom trait. This is something that Static Analysis cannot do, as Static Analysis can only skim over the assembly metadata.

There is an unfortunate drawback involved in making this switch. The Gallio adapter being used by NCrunch to integrate with XUnit does not perform very well with Dynamic Analysis. It's for this reason that the default is set to Static Analysis. You may want to experiment with this setting to see if the performance cost is worth having strongly typed categories.

There are plans to introduce direct integration between NCrunch and XUnit with the new XUnit version soon being released (XUnit V2). In doing so, performance for Dynamic Analysis will likely be improved.


Cheers,

Remco
1 user thanked Remco for this useful post.
interhan on 2/4/2014(UTC)
interhan
#3 Posted : Tuesday, February 4, 2014 1:18:12 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/13/2012(UTC)
Posts: 6
Location: Seoul

Thanks: 1 times
Thanks for clarification, I'll work with default trait for a while and once Xunit v2 and its support available, will revisit it.
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.028 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download