mstest

MSTest and NHibernate

Does anyone have any experience getting MSTest to copy hibernate.cfg.xml properly to the output directory? All my MSTests fail with a cannot find hibernate.cfg.xml error (I have it set to Copy Always), but my MBUnit tests pass. ...

Why does Visual Studio create a new .vsmdi file?

If I open a solution in Visual Studio 2008 and run a unit test then VS creates a new .vsmdi file in the Solution Items folder and gives it the next number available e.g. My Solution2.vsmdi. Any idea why VS is doing this and how I can get it to stop doing this? ...

How to Ease TDD with MSTest / VS2008

I've read time and time again that TDD/test first is more difficult with MSTest than it is with other testing frameworks such as nUnit, MBUnit, etc... What are some suggested manual workarounds and/or 3rd party bits that you suggest when MSTest is the only option due to infrastructure policy? I'm mainly wondering about VS 2008 Team Suite...

Private Accessor class ignores generic constraint

These days, i came across a problem with Team System Unit Testing. I found that the automatically created accessor class ignores generic constraints - at least in the following case: Assume you have the following class: namespace MyLibrary { public class MyClass { public Nullable<T> MyMethod<T>(string s) where T : struct { ret...

Using Resharper Unit Test Runner for MSTest via Gallio

I am attempting to get the Resharper test runner to recognize my MSTest unit tests via Gallio. I have the following installed: VSTS 2005 8.0.50727.762 Resharper 4.1 Gallio 3.0.0.285 I am also running Windows XP x64. The unit test options only shows NUnit as being available. I am thinking that I must have some versioning wrong. Can som...

VS vstest debugging error

Hi this is driving me insane. I've recently installed VS2008. The project I'm working on uses vstest and I have a maddening issue. When I choose to run/debug my tests/a test I frequently get the following error (accompanied by an exclamation mark against the test - test error): Warning: Test Run deployment issue: The assembly or module...

How do you create a custom attribute for MS Test?

If you want to create a custom attribute for MS test (say [Repeat(3)] how would you do that? ...

How can you use "external" configuration files (i.e. with configSource) with an MSTest unit test project?

For simplicity, I generally split a lot of my configuration (i.e. the contents of app.config and web.config) out into separate .config files, and then reference them from the main config file using the 'configSource' attribute. For example: <appSettings configSource="appSettings.config"/> and then placing all of the key/value pairs in...

Questions when moving from MbUnit to MsTest

Our team is looking to switch from using mbunit to mstest, but there appears to be some disconnect between the two. Does anyone know how to simulate the CombinatorialTest and Factory attributes from mbunit when using mstest? I think that is our only stumbling block before doing the switch. ...

obtain command line arguments in unit test

In a Test project in Visual Studio 2008 (Pro), I created a Test project, and I want to configure the project properties to give a command line argument to the tests. I set the properties, but then realized I have no idea how to actually use the argument. How do you get the arguments from MSTest? ...

Visual Studio MSTest run failing to even start

I've got a bunch of unit tests built using Visual Studio 2005's built-in unit testing functionality. For the last little while, it's been taking absolutely forever to start the tests... Everything just sits there at "Pending" for two minutes or more. Now Visual Studio's decided to take things to a new level and never even start the tes...

How to force a MSTEST TestMethod to reset all singletons/statics before running?

I'm using MSTEST inside Visual Studio 2008. How can I have each unit test method in a certain test class act as if it were the first test to run so that all global state is reset before running each test? I do not want to explicitly clean up the world using TestInitialize, ClassInitialize, AssemblyInitialize, etc. For example: [TestClas...

MSTest run fails because source assembly is not trusted

I just added xUnit to our test project (for the Asserts, we're still using MSTest as the framework) and immediately the test runs refused to execute any of the tests. This is the error message: Failed to queue test run '{ .... }' Test run deployment issue: The location of the file or directory '...xUnit.dll' is not trusted. ...

Sharing State Amongst TestMethods in MSTest

How do I share state amongst TestMethods in MSTest. These tests would be run as Ordered Tests and in sequence. private TestContext testContext; public TestContext TestContext { get { return this.testContext; } set { this.testContext = value;} } [TestMethod] public void Subscribe() { ...

Help troubleshooting System.BadImageFormatException:

While debugging through a .NET 3.5 SP1 project which is contacting a local web service, I'm receiving the exception System.BadImageFormatException: "Bad Class Token" Of course there aren't much more details about what's causing the exception. I can tell that the method where this occurs, which is in the same class as it's caller, the ...

How to write a MSTest unit test that listens for an event to be raised from another thread?

I’m writing a test that expects to receive an event from an object that it is calling. Specifically, I am calling out to an object that connects to an AIX machine via SSH (using the open source Granados project), then disconnecting, and I want to make sure I receive the OnConnectionClosed event that is being raised during the disconnect....

Future considerations for NUnit and NAnt

During .NET v1 days, I have tried without much success to convince colleagues to develop test-driven and automated-build work habits using the additional tools of NUnit and NAnt. When .NET Framework 2.0 and Visual Studio 2005 Team Suite came into picture, I was able to "force" my team into writing tests and provide themselves with visual...

How can I Fail a WebTest?

I'm using Microsoft WebTest and want to be able to do something similar to NUnit's Assert.Fail(). The best i have come up with is to throw new webTestException() but this shows in the test results as an Error rather than a Failure. Other than reflecting on the WebTest to set a private member variable to indicate the failure, is there s...

How can I get "Copy to Output Directory" to work with Unit Tests?

When I build a unit test project before the tests are executed the test output is copied to a TestResults folder and then the tests are executed. The issue I'm having is that not all the files in the Debug/bin directory are copied to the TestResults project. How can I get a file that is copied to the Debug/bin directory to also be copi...

Can MSTest run a specific method each time it startsup?

Question Is there a way to have a method that will always run anytime that test assembly is run through MSTest? Similar to how the [TestInitialize] and [ClassInitialize] attributes work, but for the entire assembly. I do not want to have to add code to every test class's [ClassInitialize] method. Reasoning Some of my tests interact ...