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

Notification

Icon
Error

Custom attribute not detected
jensj
#1 Posted : Wednesday, December 4, 2024 10:48:57 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/4/2024(UTC)
Posts: 1
Location: Sweden

Thanks: 1 times
Hi there ;)


My custom attribute that inherits from the standard xUnit Fact-attribute is not detected by NCrunch as far as I can tell.

I have a vague memory of this approach working before but now it it doesn't.

Any ideas what might be wrong or have changed?

Code:

public class RunnableInDebugOnlyAttribute : FactAttribute
{
    public RunnableInDebugOnlyAttribute()
    {
        if (!Debugger.IsAttached)
        {
            Skip = "Only running in interactive mode.";
        }
    }
}
Remco
#2 Posted : Wednesday, December 4, 2024 11:26:52 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi, thanks for sharing this issue.

Inheriting from Xunit attributes is basically extending the functionality of the Xunit adapter. NCrunch doesn't support this kind of extensibility, as it's impossible for us to predict how people might change the behaviour of Xunit so we have no way to implement the handling around it.

This isn't to say that inheriting from Xunit attributes won't work on NCrunch, rather that we cannot warrant that it will and can't provide help for when it fails. For this particular mechanism I recommend instead just adding a line of code to the top of the test to check for the debugger. If a generic approach is extremely important you might want to look into an AOP enabling system, perhaps an IL weaver (like Fody).
1 user thanked Remco for this useful post.
jensj on 12/9/2024(UTC)
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.026 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download