I\'m making the transition from NUnit to XUnit (in C#), and I was writing some \"Integrated Tests\" (ITs) that I don\'t necessarily want the test runner to run as part of my aut
You can use the [Trait]
attribute for that, like in the xunit example, e.g.,
[Trait ("Category", "Integration")]
This project takes it a little further and inherits categories like unit, integration, etc.
Jimmy Bogard solved this with a nice RunnableInDebugOnlyAttribute. See this blog post: Run tests explicitly in xUnit.net
public class RunnableInDebugOnlyAttribute : FactAttribute
{
public RunnableInDebugOnlyAttribute()
{
if (!Debugger.IsAttached)
{
Skip = "Only running in interactive mode.";
}
}
}
I think I found it. Apparently, you can modify your [Fact]
attribute like so: [Fact(Skip="reason")]
. This will skip the test, but you'll have no way of running it manually without modifying the attribute back to normal.
I'll keep looking for a better way.
I used
#if DEBUG
// Must test manually with https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer
[Fact]
#endif
So this is not even considered to be a test on a build server while a developer who usually builds a debug version will notice that this test fails