mstest

PropertyChanged event testing: is this a good way?

Hello everyone. I'm developing WPF applications using MVVM pattern. I have ViewModel with code like this: public bool EditModeEnabled { get { return _EditModeEnabled; } set { _ModeEditModeEnabled = value; OnPropertyChanged("EditModeEnabled"); OnPropertyChanged("CommentTextBoxVisibility"); } } O...

TestInitialize gets fired for every test, in my Visual Studio unit tests?

Hi folks, i'm using Visual Studio 2010 Beta 2. I've got a single [TestClass], which has a [TestInitialize], [TestCleanup] and a few [TestMethods]. Every time a test method is ran, the initialize and cleaup methods are ALSO ran! I was under the impression that the [TestInitialize] & [TestCleanup] should only be ran once, per local tes...

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 i VS. We are, however, also running continous integration with TeamCity, and in TeamCity...

Is there a way to write tests for a Interface and then test it against all classes that implement the test?

I've already checked this.. similar question but I am not convinced about the answers... I currently have an interface that is only being implemented by one class, but that is going to change sooner or later. I currently have a test against the interface, and all tests at the beginning start with: IFoo foo = GetConcreteFoo() where Ge...

In MSTest, How can I verify exact error message using [ExpectedException(typeof(ApplicationException))]

using MS Test how can verify the exact error message coming from a test method. I know [ExpectedException(typeof(ApplicationException), error msg)] doesn't compare the error message coming from my test method, though in other unit test framework it is doing. One way to solve this problem is to write my uni test using some try catch bloc...

How can i reference an embedded data file for data-driven unit tests?

This is my scenario, I want to make a Data-Driven unit test, and for being environment-independent i want to embed the data file in my assembly. How can i reference then in the DataSourceAttribute of the Unit Test?. I'm trying to access an Excel 2003 file using the Microsoft Jet OleDB Provider. The unit test works fine when the file is ...

Is anyone actually succesfully using MSTest across the team??

Hi, I've been using MSTest so far for my unit-tests, and found that it would sometimes randomly break my builds for no reason. The builds would fail in VS but compile fine in MSBuild - with error like 'option strict does not allow IFoo to cast to type IFoo'. I believe I have finally fixed it, but after the bug coming back and struggling...

Visual Studio 2008 Test Run taking long to Complete

I have a bunch of test projects in my solution. Most of them run instantly and finish instantly. One however takes a long time to complete. The actual tests run fast, but for a long period after all the tests have passed the interface still says "Test Run Completing...". The test run eventually finishes after 10-20 seconds. Has anyone ex...

Can you build your own MSTEST DataSource

I have been looking for a way to build my own DataSource for data driven unit tests in MSTEST. I have not found any documentation how to do this or any base class or interface that I need to implement. Any ideas? I'm looking at building something similar to FITNesse but using Team Foundation Server for my backing store. ...

Is there a third party tool that actually speeds up MSTest

There a lot of questions very similar to this. Please read before you decide it is a duplicate. I have seen several people suggest that TestDriven.NET will help my slow MSTest woes. Most of them point to the ability to run a single test easier. I have resharper which can run a single test easily. So my question is, does TestDriven.N...

System.Web.HttpException: 'http://localhost:3434' is not a valid virtual path..

I am writing unit test cases using mstest. one of the method will change the Http to Https. string url=http://localhost:3434 string expected=https://localhost:3434 string actual=ReplcaeTheUrl(url);//this will replace Http to Https Assert.AreEqual(expected,actual); Here my test case are failing by giving an exception System.Web.HttpE...

DeploymentItem Attribute causes all tests in test class to fail with error "Unable to create instance of class [TestClass]"

Hi Everyone. I'm getting a strange error when I try to run a set of unit tests where the class has a DeploymentItem attribute. The unit testing solution has 2 test classes, one to test business logic which I'll refer to as 'class a' (this one works fine regardless) and one to test reading of data from the DeploymentItem file which I'll...

Mobile Emulator Launched for non-mobile unit tests

I have a Compact Framework Project that has two Unit Test projects with it in the solution. One is a Smart Device Unit Test Project (needs the emulator to run). The other is a normal Unit Test Project. The normal Unit Test Project runs fine on my machine and on the build machine, but on my co-worker's machine it tries to launch the em...

Choosing a test platform for .NET - MbUnit or the one by Microsoft?

I have chosen these two as primary candidates. My thinking goes like this: MbUnit has had a nice start and enjoys a smart, dedicated team of developers. MSFT has many resources and can compete with MbUnit easily if they choose to do so. Which one do you believe I should bet on? ...

MSBuild not compiling MSTest projects (from TeamCity)

Im using MSBuild 10 to compile a .Net solution file which includes a MSTest project. Im using MSBuild from within TeamCity. MSBuild doesnt seem to be building the test project and so the test project dll isnt created for use by MSTest, although the other projects are compiled OK. What do I need to do to get the test project to compile ...

Unit Test configuration for ASP.NET application

This is my first test for Asp.Net Web Application. We have an Engine consisting of several modules. I need to test classes in Engine Module. Though these clases are part of Asp.Net App, they consists of only business logic. How can I test these classes in isolation other being part of WebApp ? because i am getting this error The Web r...

VB.Net: how can I get the source path of the assembly while running MSTest?

I'm trying to switch from NUnit to MSTest (for the Code Coverage option). We have some of the configuration for the application stored in files (the application finds them by using a relative path, starting from the "bin" folder, where the .dlls are). NUnit worked fine with this configuration. MSTest copies the .dlls in a test folder ...

Is there an API for running Visual Studio Unit Tests programmatically?

Is there an API for running Visual Studio Unit Tests programmatically? Running MSTests.exe with Process.Start() does not work in the current scenario. What I'm looking for is something like the NUnit SimpleTestRunner. Any ideas? /Erik ...

Is it possible to use Microsoft.VisualStudio.QualityTools.UnitTesting.CollectionAssert on an IEnumerable<T>?

I have a testing scenario where I want to check if two collections are equal. I have found the class Microsoft.VisualStudio.QualityTools.UnitTesting.CollectionAssert, but it only works on ICollection<T>. Since I'm testing a repository for Entity Framework, and thus need to compare IObjectSet<T>s, that won't do - IObjectSet<T> doesn't imp...

MSTest Test Context Exception Handling

Is there a way that I can get to the exception that was handled by the MSTest framework using the TestContext or some other method on a base test class? If an unhandled exception occurs in one of my tests, I'd like to spin through all the items in the exception.Data dictionary and display them to the test result to help me figure out wh...