Ignoring specific unit tests at run time

You can use an [Ignore] attribute to decorate your unit test, when you need to have a unit test that is both handy but not critical to test a functionality. This unit test will be ignored, when running this unit test in Visual Studio or on a build server.


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

   // ARRANGE
   var customerNumber = "1731084";
   var customerService = new CustomerService();

   // ACT
   var result = customerService.GetCustomer(customerNumber);

   // ASSERT
   Assert.IsNotNull(result);
   Assert.IsTrue(result.CustomerNumber == customerNumber);
}

For more information check MSDN about the IgnoreAttribute Class. Enjoy!