mstest

Build failing - VS2010 solution on TFS2008

I have migrated a VS2008 ASP.NET MVC solution to VS2010/MVC2/.NET 4.0 The solution builds locally and all unit tests pass. Our TFS server is still TFS2008 and I am having problems getting the CI build to pass. The projects all build successfully, the unit tests all run and pass but the Running Tests item fails. I followed this blog p...

Using content from the project in tests

I am working with Visual Studio 2010 and it's integrated testing functionality. I have an XML file in my project which is set to copy to the output directory. I can access the file just fine when I compile and run the project. But it doesn't exist when I attempt to access it within a TestMethod. It looks like the test is run with the ...

Does someone have used Network Emulator API exposed in VS 2010

Hi, I have seen VS2010 exposing Network Emulator API. I have installed it and trying to use this API, but not able detect whether it is really running with this code or not. Sometime I have given wrong profile name but it does not throw any error. Please find below my piece of code. If some one have used it please help me. IntPtr m_emu...

New NCover 3.4.2 makes all my MSTest unit tests fail

Yesterday, I decided to install the newest NCover version (3.4.2). However, when I ran it on my existing .ncover configuration file, the NCover output suddenly reported that all my MSTest tests failed. Of course those tests succeed when ran within Visual Studio. Because of this, NCover isn't able to determine any coverage. Somehow the o...

Using inheritance in MSTest

I am setting up some MSTest based unit tests. To make my life easier I want to use a base class that handles the generic setup and taredown all of my tests require. My base class looks like this: [TestClass] public class DBTestBase { public TestContext TestContext { get; set; } [ClassInitialize()] public static void MyCla...

Web.Config issue with Unit Testing

I am trying to unit test a lot of my MVC controllers, but unfortunately it keeps failing because it needs a lot of settings from the web.config.. Which I copied over but does not read it, what I'm needing is the membership and rolemanager but I can't just add it to the app.config either, which I've been able to get the connection string...

Is the test suite setup method executed once for each test, or only once for all?

I know the answer may differ for each test framework. But for the ones you know, what should happen? ...

ReSharper wrapping test result stacktraces?

ReSharper 4.5's test runner will run MSTest tests out of the box, and that's what I'm doing. When a test fails, I click on the test to see the stacktrace and the failure reason. The pane I'm clicking in to do this is the "Unit Test Sessions" pane. The lower half of this pane (or the right half, if you have it configured that way) show...

How do you unit test a class that's meant to talk to data?

I have a few repository classes that are meant to talk to different kinds of data, deriving from an IRepository interface laid out like so: In implementations, the code talks to a data source, be this a directory of XML files or a database or even just a cache. Is it possible to reliably unit test any of these implementations? I don't...

Test run errors with MSTest in VS2010

When I run my Unit Tests, all tests pass, but instead of "Test run succeeded" or whatever the success message is, I get "Test run error" in the little bar that tells me how many of my tests pass, even though all my tests passed. When i click the text, I'm taken to a page that tells me the following two things happened: Warning: conf...

Visual Studio 2008 Unit test does not pick up code changes unless I build the entire solution

Here's the scenario: Change my code: Change my unit test for that code With the cursor inside the unit test class/method, invoke VS2008's "Run tests in current context" command The visual studio "Output" window indicates that the code dll and the test dll both successfully build (in that order) The problem is however, that the unit t...

Copy all files/subfolders to Testrun Out dir?

I need to copy all files and subfolders from a specified path to my testrun Out folder. I only want this to happen for certain tests (so, no global solution, like the Deployment section in the Testrunconfig file). I have a solution structure like this Solution\ Project\ Project.Test\ Resources\ FolderA\ Fold...

Castle interceptor does not intercept a method on an MVC Controller during unit test

I have a .net test class. In the Initialize method, I create a windsor container and make some registrations. In the actual test method, I call a method on the controller class but the interceptor does not work and the method gets directly called. What are potential reasons for this? Here is all the related code: Test.cs: private Some...

Make a UNC path trusted for DLL referencing on Server2008R2

I need to run MSTest on an assembly referenced by a UNC path. When I try I get a generic error, which Google tells me is trust related.The machine where MSTest runs and the network host are both Server2008R2 (in some circumstances the same machine). For example, running this works fine: mstest /testcontainer:c:\builds\SimpleLibraryT...

VS 2010 Test Runner error "The agent process was stopped while the test was running."

In Visual Studio 2010, I have a number of unit tests. When I run multiple tests at one time using test lists, I sometimes reveive the following error for one or more of the tests: The agent process was stopped while the test was running. It is never the same test failing, and if I try to run the test again, it succeeds. I found ...

TFS and code coverage for web application (MVC) assemblies not working

I've got an MVC web application with associated controller tests that run under a TFS build as per normal. I can see the tests running and passing in the build log and they appear in the "Result details for Any CPU/Release" section of the build I also have a number of other assemblies with associated tests that are running in the same ...

Results published with MSTest not appearing in TFS2010 reports

I'm trying to publish test results to TFS2010 using MSTest's /publish parameters. MSTest says that the publish was successful, and looking at the SQLServer tables, data for the test has been uploaded. However, the test results do no appear in the TFS Build reports. If I use TFS to run MSBuild via the default build template, the results...

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

Is there something like that in MSTest? Thanks ...

Visual Studio 2010 and Test Driven Development

I'm making my first steps in Test Driven Development with Visual Studio. I have some questions regarding how to implement generic classes with VS 2010. First, let's say I want to implement my own version of an ArrayList. I start by creating the following test (I'm using in this case MSTest): [TestMethod] public void Add_10_Items_Remove...

Automapper error first time we run Unit Tests with MSTest

We are getting an Automapper error the FIRST time we run our Unit Tests in VS 2008 (MSTest). "Missing type map configuration or unsupported mapping. Exception of type 'AutoMapper.AutoMapperMappingException' was thrown" If we re-run the tests ("Run Checked Tests") then they all pass. Only 2 out of the 4 developers are having this issue. ...