C# Quicktip: In Xunit how to skip a unit test from being run

While working on my project I was looking for a way to temporarily skip a unit test because I had temporarily changed some behavior, causing the test to fail. I didn’t want to remove the test and commenting out the test seemed a bit dirty. So I discovered that there is a way to tell Visual Studio (or whatever is running your tests) to temporarily skip a test. Here is how to do it.

Wouter
3 min readApr 7, 2022

When using the default testing framework (I believe it is called MSTest) in .NET your tests will be decorated with a [testmethod] attribute.

If you want to skip or ignore a test from being run you can just place the ignore attribute above them. When you have the [ignore] attribute above a [testmethod] the test will be skipped. For example:

[TestMethod]
[Ignore]
public void TestStartAcquireEmpty()
{

}

However I was using Xunit. And when using Xunit the syntax is a bit different.

Using Xunit

--

--