Can you mark XUnit tests as Explicit?

后端 未结 4 1424
你的背包
你的背包 2021-02-05 05:43

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

4条回答
  •  青春惊慌失措
    2021-02-05 05:55

    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.";
            }
        }
    }
    

提交回复
热议问题