What would be an alternate to [TearDown] and [SetUp] in MSTest?
You would use [TestCleanup] and [TestInitialize] respectively.
You would use [TestCleanup] and [TestInitialize] respectively.
I was able to track down the answer. According to Microsoft employee Guillermo Serrato: MSTest executes all tests synchronously, the order is nondeterministic
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
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
The standard way to do this is by specifying the deployment items in the .testrunconfig file, which can be accessed via the Edit Test Run Configurations item in the Visual Studio Test menu or in the Solution Items folder.
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
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
You can install the Prism file in the GAC of your build server.
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”); }
To make assertions about collections, you should use CollectionAssert: CollectionAssert.AreEqual(expected, actual); List<T> doesn’t override Equals, so if Assert.AreEqual just calls Equals, it will end up using reference equality.