mstest

What dynamic language can I use for .NET unit tests?

I am trying to write some complicated acceptance tests for my C# code. I notice that when I am writing my tests I am doing a lot of explicit casting to satisfy the C# compiler. I like the type-safety I get in my production code with a statically-typed language like C#, but for my tests I would be happy to use a dynamically-typed language...

How can a webtest be made to accept file downloads?

I'm using Visual Studio Team Foundation Server 2008 Team Suite to create a webtest for a site. On some pages the response is a file download (usually a PDF), and I just need to test that the response comes back with the right status code and content type, ignoring the body. When I run the webtest in Visual Studio, or run the compiled t...

What is PriorityAttribute Used for in MSTEST / Visual Studio

I noticed the existence of Microsoft.VisualStudio.TestTools.UnitTesting.PriorityAttribute. From reading a little about it, it does not seem to have anything to do with the test execution order. That being the case, it begs the question: what is it used for? I'm curious, are there any known uses of this attribute either by Visual Studio ...

Repeat mstest test run multiple times

Some of my mstest unit tests help detect multi-threading race conditions, and as such they are most useful when run many times in a row, but I only want to do this for specific test runs -- not all the time. Is there a way to configure mstest (in the Test List Editor preferably) to run a test multiple times? ...

Mock ASP.Net User in WebForms app

I have a legacy app that I am trying to build some testing into. I have some tests that require the HttpContext.Current.User Is there a way to mock this, or simply login a user on the fly? ...

Create and drop a database defined using Visual Studio Team System 2008 Database Edition

How do I create and drop a database defined using Visual Studio Team System Database Edition from inside a unit test? (I guess that makes it more of a integration test...) I want to be able to create the database either for each test or for a suite of tests and then drop the database after each test or suite of tests. Is there an API I...

Running MSTest with tests against different databases

Hello guys, I would like to ask what is the best way to execute a setup like the following: We have tests suite that is compiled, and in the app.config file I have 6-7 different connection strings to different databases. I would like to run the tests suite against every connection, and I hoped to parametrize in some way this process - so...

Value of type '<typename>' cannot be converted to <typename>.

I'm working on a project that uses the testing tool built into VS 2008. Periodically I will see an error comparable to: Value of type 'AcademyPro.Code.BLL.Appearance' cannot be converted to 'AcademyPro.Code.BLL.Appearance'. Type mismatch could be due to the mixing of a file reference with a project reference to assembly 'AcademyPro'. Tr...

MSTest: Problems with DeploymentItem attribute

Hi, I'm currently maintaining an "old" system written in C#.net, removing some obsolete features and doing some refactoring. Thanks god, the previous guy wrote some unit tests (MSTests). I quite comfortable with JUnit tests, but didn't do yet much with MSTests. The test methods have a DeploymentItem attribute, specifying a text file wh...

VS2008 MSTest command line program hanging when loading unit test assembly

Within Visual Studio 2008 SP1, you can create a unit test project which uses MSTest as the test runner. I've been writing tests now at work that test unmanaged C++ MFC from the managed MSTest project, and it's been quite an interesting ride. There seems to be a difference between using the IDE's test runner versus using the command lin...

.NET + TeamCity: Private Accessors Are Not Compiled

I'm running Team City Pro (v4.0.2 build 8222) for a VS2008 sln file. Right now I'm facing a problem where autogenerated code for private accessors in a test project not being generated and causes compile errors by not being able to find those (autogenerated) classes. The build runner is the default sln2008. Any configuration need to b...

How does Assert.AreEqual determine equality between two generic IEnumerables?

I have a unit test that will test to see if a method that returns the correct IEnumerable. The method builds the IEnumerable using yield return. The class that it is an IEnumerable of is below: enum TokenType { NUMBER, COMMAND, ARITHMETIC, } internal class Token { public TokenType type {get; set;} public string te...

MSTest - problem with private accessors

I'm having a problem with MSTest where I'm getting hundreds of error messages along the following lines when I build my solution: The best overloaded method match for 'ClassName_Accessor(Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject)' has some invalid arguments Argument '1': cannot convert from 'SomeObject' to 'Micr...

How to use MsTest in Continous Integration without VS ?

I my problem is quite simple, i have a CI server wich run msbuild and mstest. The problem is that the Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll doesn't exist( and i thinks other file related to mstest...) if we don't install VS in the server wich is pretty stupid for a CI server... Anybody have a solution about this pr...

Unit testing for invalid enum value

I have a lump of code that looks a bit like this: If mode = DiaryMode.Admin Then modeObject = DBNull.Value ElseIf mode = DiaryMode.Academy Then modeObject = ApplicationSettings.Academy ElseIf mode = DiaryMode.Scouting Then modeObject = ApplicationSettings.Scouting Else Throw New NotSupportedException() End If The idea ...

Why is it not possible to inherit tests methods from other assemblies

WHy is it not possible to inheritance tests from other assemblies to run: namespace TestProject.Base { [TestClass] public abstract class TestBaseClass { [TestMethod] public void BaseTest() { Assert.IsTrue(false); } } } Test Runner namespace TestProject.UnitTest { [...

How to migrate a nunit-config-file to mstest?

I would migrate all my unit tests from nunit to mstest. In the solution I have a nunit-config file, which looks like that: <NUnitProject> <Settings activeconfig="Web"> <Config name="Web" appbase="Web" configfile="web.config" binpathtype="Auto"> <assembly path="bin\Product.NUnit.ComponentA.dll"/> <assembly path="bin\Product.NUnit...

[AssemblyInitialize] and TestDriven.Net

Has anyone experienced any issues with using the mstest attribute [AssemblyInitialize] when running tests with TestDriven.Net? I've tried 2.14 RTM and 2.22 RTM and neither seem to work for me. When I execute the test, the assembly init method isn't being executed. It's like TD.Net doesn't recongize the attribute. Any tips/ideas/clues i...

Can I create a wrapper around NUnit, MbUnit, xUnit or other testing framework?

How can I create a wrapper around a testing framework? We still doesn't know which testing framework are going to use, but I need to start writing unit tests. With this question I want to know how can I switch from NUnit to mbUnit, xUnit or even MSTest. ...

Does MSTest Have an Equivalent to NUnits TestCase

I find the TestCase feature in NUnit quite useful as a quick way to specify test parameters without needing a seperate method for each test. Is there anything similar in MSTest? [TestFixture] public class StringFormatUtilsTest { [TestCase("tttt", "")] [TestCase("", "")] [TestCase("t3a4b5", "345")] [Tes...