Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create unit tests which runs only when manually specified?

Tags:

I remember something like 'explicit', and google says that nunit has such attribute. Does Microsoft.VisualStudio.TestTools.UnitTesting provide something like this?

like image 537
st78 Avatar asked Feb 08 '10 17:02

st78


People also ask

Can unit testing be performed manually?

Unit tests can be performed manually or automated. Those employing a manual method may have an instinctual document made detailing each step in the process; however, automated testing is the more common method to unit tests. Automated approaches commonly use a testing framework to develop test cases.

How do I run a specific unit test in Visual Studio?

Run tests in Test Explorer If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.


1 Answers

The MSTest tools does not explicitly support this type of behavior at an attribute level. At the attribute level you can either enable a test via the TestMethod attribute or completely disable it with the Ignore attribute. Once the Ignore attribute is added, mstest will not run the test until it is removed. You cannot override this behavior via the UI.

What you can do though is disable the test via the property page. Open up the test list editor, select the test you want and hit F4 to bring up the property page. Set the Test Enabled property to false. The test will now not run until you re-enable it through the property page. It's not exactly what you're looking for but likely the closest equivalent.

like image 69
JaredPar Avatar answered Sep 21 '22 20:09

JaredPar