Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an MSTest equivalent to NUnit's Explicit Attribute?

Is there an MSTest equivalent to NUnit's Explicit Attribute?

like image 527
devoured elysium Avatar asked May 15 '10 22:05

devoured elysium


People also ask

Which is better MSTest or NUnit?

The main difference is the ability of MsTest to execute in parallel at the method level. Also, the tight integration of MsTest with Visual Studio provides advantages in both speed and robustness when compared to NUnit. As a result, I recommend MsTest.

What is MSTest and VSTest?

Visual Studio includes the VSTest and MSTest command-line tools for testing purposes. We can use both VSTEST and MSTEST to run automated unit and coded UI tests from a command line. 1. VSTest. Console.exe is optimized for performance and is used in place of MSTest.exe in Visual Studio.

What is difference between NUnit and xUnit?

NUnit will run all the tests using the same class instance, while xUnit will create a new instance for each test.


2 Answers

No, the closest you will get is with the [Ignore] attribute.

However, MSTest offers other ways of disabling or enabling tests using Test Lists. Whether you like them or not, Test Lists are the recommended way to select tests in MSTest.

like image 67
Mark Seemann Avatar answered Sep 24 '22 04:09

Mark Seemann


When you want the test only to assert when ran with the debugger (implicitly run manually I assume) then you may find this useful:

if (!System.Diagnostics.Debugger.IsAttached) return; 

Add the line above at the beginning of the method marked with [TestMethod]. Then the test is always ran, but nothing is asserted when there is no debugger attached.

So when you want to run it manually, do it in debug mode.

like image 36
Mike de Klerk Avatar answered Sep 20 '22 04:09

Mike de Klerk