mstest

MS Test error when running all tests

I am currently working on a project that is using MS Test for unit testing. When I do a "Run All Tests" I get the following error for about 1/3 of the tests: Test method [Test Method] threw exception System.IO.FileLoadException, but exception System.InvalidOperationException was expected. Exception message: System.IO.FileLoadException...

Msbuild copy and flatten with unique file names

I'm trying to copy multiple files from a deep source tree that have the same file name. For example TestResults.trx. I want to copy them into a single directory (i.e. flattened). Problem is they just overwrite each other and I just end up with a single TestResults.trx in the directory. <ItemGroup> <SilverlightTestResults Include=".\...

Team Build: Cannot find generated private accessor

We have been using TeamBuild and test for our continuous integration build for about 4 months and this issue just popped up the other day in one of our test assemblies when running tests on one of our test assemblies on the build server only. {NameSpace}.Order_Accessor, Version=0.0.0.0, Culture=neutral, PublicKeyToken='{xxx}' or one of ...

How to run all tests when I click F5 in Visual Studio 2008 Professional

I have a solution in Visual Studio 2008 professional. There are three projects, a Windows Form project and two MSTEST projects. The Windows Form project is set as the startup. When I click F5 to run the Windows Form project in debug mode, I would like to get all the tests to run from both MSTEST projects. I tried starting all three pro...

How to use multiple localtestrun.testrunconfig files in a solution

Hi, I am interested in how Visual Studio picks up a localtestrun.testrunconfig file and then how it uses it to establish which files to deploy to the test run folder? I currently have two problems: I have a visual studio 2008 solution which has both a web application project and a web services host project. I would personally prefer...

IEnumerable and yield return

My unit tests are doing something very strange when I call a method of a generic base type. I have tried both NUnit and MSTest with the same result. This is how the code is organized: public class MyStub {} public class EnumerableGenerator { public bool GotMyStubs; public IEnumerable<MyStub> GetMyStubs() { GotM...

C# using static variable as parameter to DeploymentItem

I want to use a static variable as the parameter to DeploymentItem on an MSTest unit test but it doesn't seem I'm able to do so. There's an XSL file that needs to be copied along with the DLL file when the unit test runs, and I defined the location as private static string _xslPath = Path.Combine("MyProjectDir", "transform.xsl"); How...

C# DeploymentItem fails to copy file for MSTest unit test

I'm having trouble getting an XSL file to be copied to the same directory as the test assembly when I use the DeploymentItem attribute on an MSTest unit test. I followed the chosen answer for this question and the file I need copied has its "Copy to Output Directory" set to "Copy Always". When I check my ProjectDir\bin directory (the T...

cannot load web.config in mstest

I need read connection string from web.config which in asp.net mvc project, but all i get are null. how can i obtain connection string in mstest, do i need additional configuration in some where? ...

Unit testing - How to set up test data when stubbing database data

Hi, In our unit testing, I've got a stub object that is creating a set of data in memory to be used during unit testing so that the live database is not used. I have unit tests that check the number of rows returned from this set using the query under test and the values supplied to the query in the test. My first issue is that because...

MSTest with Moq - DAL setup

I'm new to Moq, and just started on a project that's already in development. I'm responsible for setting up unit testing. There's a custom class for the DatabaseFactory that uses EnterpriseLibrary and looks like this: public Database CreateCommonDatabase() { return CreateDatabaseInstance(string.Empty); } private static Database Creat...

In MSTests is it possible to catch any exception?

I am trying to avoid a brittle test. I'd like to assert that a method throws an exception when invalid data is passed in, and I don't care which one. Take String.IsNullOrEmpty for instance, if the string is empty you don't want to throw a nullreference exception right? if it's null you I suppose you could throw an argumentException. I d...

Debug.Assert interferes with MSTests, how do I work around it?

So I have a method i'm unit testing via MSTests to ensure it throws an exception properly on bad data coming in. However that method has Debug.Assert so it's caught while debugging if it happens during an actual test where I'm in debug mode trying to find a bug. So the unit tests fail at being automatable when run in this way because...

How to use CollectionAssert (and Linq?) to find all the values for one property, are the same?

Hi folks, this is an extension to a previous question I asked, today .... which highlighted the use of CollectionAssert to help test collections (which I never knew). I have an ICollection<Foo> foos; This has a property called Status, which .. to keep things simple, is an int or byte (whatever floats your boat <-- see what I did there?...

Object Comparison in Unit Testing

I have two objects in my unit test, the actual and expected object. All properties on the object method are the exact same and if I run the following test: Assert.AreEqual( expectedObject.Property1, actualObject.Property1); the result passes as expected. However, when I try to run the following test it fails: Assert.AreEqual (expec...

Integration testing private classes and methods

For unit testing you shouldn't test private methods, yes, but for integration tests (using a unit testing framework like MSTest or NUnit) I would very much like to run the internal API calls against a test url, to make sure the current code works when the third party API vendor changes their backend. Given the complexity of the system (...

How to get MSTest to work with Gallio/MBUnit?

How to get MSTest to work with Gallio/MBUnit? I am trying to get TeamCity to work with Gallio/MBUnit and also some legacy MSTest unit tests. The MSTest section fails with a "Exception has been thrown by the target of an invocation" error message. Problem seen with GallioBundle-3.1.397.0-Setup-x64.msi. ...

Unit Tests Execute Really Slowly in Visual Studio 2008

I downloaded the MVC Storefront source code from Codeplex (http://mvcsamples.codeplex.com/) (the "Recommended Download", not from the most recent source code). If I click the "Run all tests in solution" button in VS 2008, the tests start to run, but they take about 3 seconds EACH, and there are 194 tests which would take about 10 minut...

How to only show test results window on test failure with MSTest in Visual Studio 2008?

I'm using Visual Studio 2008 Professional and have added an MSTest project to my solution. Every time I run my tests (within VS), the "Test Results" window is displayed at the bottom of the IDE. I would like this window to be displayed only when one or more tests have failed. Does anyone know if there is a way of configuring this behavi...

Exception when running mstest.exe: Microsoft.VisualStudio.TestTools.Utility.LicenseHelper. How to fix?

I recently updated our build server, including Service Pack for Visual Studio 2008. I used to be able to run mstest.exe on the command line and from Cruise Control successfully. After the update however i get this error message: C:>"c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe" Microsoft (R) Test Exe...