Questions tagged [mstest]

Microsoft .NET Unit Testing Framework (MSTest)

Microsoft .NET Unit Testing Framework - MSTest to integrate unit testing (also load testing, coded UI testing, etc.) into Visual Studio.

MSTestv2 contains a command-line utility that helps you run automated tests. You can run all or specific tests contained in a test assembly or event categorize them by:

  • Test Categories
  • Test Type
  • Test Lists

It also has an option to publish the test results in a Team Project on Tfs.

3252 questions
35
votes
6 answers

How slow is too slow for unit tests?

Michael Feathers, in Working Effectively With Legacy Code, on pages 13-14 mentions: A unit test that takes 1/10th of a second to run is a slow unit test... If [unit tests] don't run fast, they aren't unit tests. I can understand why 1/10th a…
Matt
  • 14,353
  • 5
  • 53
  • 65
34
votes
3 answers

MSTest and app.config issue

I am stuck trying to automate unit tests runs with MSTest and deployment of app.config. I read multiple posts and blogs, tried multiple things and yet still app.config doesn't seem to be picked up during MSTest execution. Having a dll that contains…
kateroh
  • 4,382
  • 6
  • 43
  • 62
34
votes
8 answers

How do I enforce exception message with ExpectedException attribute

I thought these two tests should behave identically, in fact I have written the test in my project using MS Test only to find out now that it does not respect the expected message in the same way that NUnit does. NUnit (fails): [Test,…
CRice
  • 12,279
  • 7
  • 57
  • 84
32
votes
7 answers

How can I use PrivateObject to access private members of both my class and its parent?

I'm testing a class that is part of a hierarchy. I've been setting up my test classes with the object under test, and a PrivateObject to allow access to that object. I'm getting exceptions when I attempt to access private members of the parent…
David Yaw
  • 27,383
  • 4
  • 60
  • 93
32
votes
3 answers

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

Is there an MSTest equivalent to NUnit's Explicit Attribute?
devoured elysium
  • 101,373
  • 131
  • 340
  • 557
31
votes
1 answer

Using MS Test ClassInitialize() and TestInitialize() in VS2010 as opposed to NUnit

I've used NUnit with VS2008, and now am adapting to MSTest on VS2010. I used to be able to create an object in TestSetup() and dispose of it in TestCleanup(), and have the object created each time a test method was run in NUnit, preventing me from…
Jennifer S
  • 1,419
  • 1
  • 24
  • 43
31
votes
1 answer

In Visual Studio Test, how to make a playlist which automatically excludes certain tests?

Our team has Visual Studio 2012 Professional licenses (not Test Professional). We are developing a smallish web application, and we have both true unit tests which mock everything needed, and tests for the data layer. Each class of data layer tests…
Rumi P.
  • 1,688
  • 3
  • 23
  • 31
30
votes
13 answers

BadImageFormatException when AnyCPU test assembly implements interface from x64 production assembly

I seem to have hit on a scenario where when I run mstest on an AnyCPU assembly which references an x64 assembly, I get a BadImageFormatException. The issue occurs when an interface in x64Production.dll is implemented (even if unused) by the…
David
  • 313
  • 1
  • 4
  • 8
30
votes
5 answers

MSTest: CollectionAssert.AreEquivalent failed. The expected collection contains 1 occurrence(s) of

Question: Can anyone tell me why my unit test is failing with this error message? CollectionAssert.AreEquivalent failed. The expected collection contains 1 occurrence(s) of . The actual collection contains 0 occurrence(s). Goal: I'd…
Lernkurve
  • 20,203
  • 28
  • 86
  • 118
30
votes
2 answers

DataTestMethod vs TestMethod

I started to use MSTest 2 DataRow attributes to check multiple cases in a single test: [TestMethod] [DataRow(1, 1, 2)] [DataRow(1, 2, 3)] public void AdditionWorks(int op1, int op2, int expectedResult) { Assert.AreEqual(expectedResult, new…
Lukáš Lánský
  • 4,641
  • 3
  • 32
  • 48
30
votes
3 answers

How to get MSTest to find my test data files?

I have a few tests that need to be fed with external data from excel files. The files are included in the test project, and in Visual Studio, I have edited the test settings file (Local.testsettings) to deploy the data files. This makes it work fine…
Johan Driessen
  • 841
  • 2
  • 8
  • 13
29
votes
6 answers

How to Unit Test JsonResult and Collections in MSTest

I am very new to unit testing even though i have been coding for a very long time. I want to make this a part of my way of development. I run into blocks on how to unit test things like a collection. I generally have my jQuery script calling ASP.Net…
mithun_daa
  • 4,334
  • 5
  • 38
  • 50
29
votes
6 answers

Failed to initialize client proxy: could not connect to vstest.discoveryengine.x86.exe

Before, I was able to run the unit tests of a particular project under Visual Studio 2013 just fine. This has recently stopped working without major changes to the project, and unfortunately I do not recall when it did last work, nor what changed…
Steven Jeuris
  • 18,274
  • 9
  • 70
  • 161
29
votes
5 answers

How do you create a unit test assembly for a .NET Portable Class Library?

I am attempting to unit test a Portable Class Library that I've created and I want to make sure it's being tested with the same framework subset that it targets. Per the Visual Studio ALM + Team Foundation Server blog, the MSTest unit test framework…
Travis Illig
  • 23,195
  • 2
  • 62
  • 85
28
votes
2 answers

what is the equivalent test attribute for TestFixtureSetUp of Nunit in MSTest

In NUnit we use TestFixtureSetUp what is the equivalent test in MSTest? Thanks
kumar
  • 8,207
  • 20
  • 85
  • 176