Where is the “Create Unit Tests” selection?

This feature was cut from VS. http://blogs.msdn.com/b/visualstudioalm/archive/2012/03/08/what-s-new-in-visual-studio-11-beta-unit-testing.aspx Generate Unit Test Wizard – In VS2010 you could right click on a method in your code and we would generate a unit test into your test project. This wizard was very tightly coupled to MS-Test and depended on features like Private Accessors to do its work, so … Read more

How do you run SpecFlow scenarios from the command line using MSTest?

Behind the scene specflow tests are just regular mstest unit tests. So you should be able to run them the same way using something like: To run a specific scenario: mstest /testcontainer:tests.dll /test:GivenMyScenarioWhenIDoSomeStuff To run a several specific scenario you can use the /test flag multiple times: mstest /testcontainer:tests.dll /test:GivenMyScenarioWhenIDoSomeStuff /test:GivenMyScenarioWhenIDoSomemthingElse To run a feature … Read more

Why does TestInitialize get fired for every test in my Visual Studio unit tests?

TestInitialize and TestCleanup are ran before and after each test, this is to ensure that no tests are coupled. If you want to run methods before and after ALL tests, decorate relevant methods with the ClassInitialize and ClassCleanup attributes. Relevant information from the auto generated test-file in Visual Studio: You can use the following additional … Read more

Can I use mstest.exe without installing Visual Studio?

It is possible to run mstest.exe without visual studio. Download one of the Agents for Visual Studio ISO’s below and install the Test Agent on the server: Visual Studio 2019 Visual Studio 2017 (127MB disk space, less than that for download) Visual Studio 2015 and older: visit https://www.visualstudio.com/vs/older-downloads/ and follow the instructions This installs everything … Read more

How do I use Assert to verify that an exception has been thrown with MSTest?

For “Visual Studio Team Test” it appears you apply the ExpectedException attribute to the test’s method. Sample from the documentation here: A Unit Testing Walkthrough with Visual Studio Team Test [TestMethod] [ExpectedException(typeof(ArgumentException), “A userId of null was inappropriately allowed.”)] public void NullUserIdInConstructor() { LogonInfo logonInfo = new LogonInfo(null, “P@ss0word”); }