English 中文(简体)
Unit Testing .NET 3.5 projects using MStest in VS2010
原标题:

There s a bug/feature in Visual Studio 2010 where you can t create a unit test project with the 2.0 CLR.

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=483891&wa=wsignin1.0

This causes all sorts of problems when the project being tested is targetting the 2.0 CLR (ASP.NET MVC 2 on top of .Net 3.5 SP1 in this case) - crashes on debug, tests failing unexpectedly, in one case the test project doesn t even build because of the dependency on System.Web 2.0.0.0 which isn t available in projects targetting 4.0.

It s not possible to change the test project to target the 3.5 framework.

Does anyone know of a workaround?

Workarounds I m aware of, but want to avoid, include:-

1) Upgrading the whole solution to target .NET 4
I want to host on Azure and it isn t clear at this point if/when support for .NET 4.0 will be added. See .NET 4.0 on Windows Azure?

2) Rolling the whole project back to Visual Studio 2008
This is a last resort as there are a number of features in 2010 that I really want to use

3) Building the unit tests in 2008 and managing the references manually
This will work, but it ll be a tremendous pain.

Any ideas?

最佳回答

It looks like Visual Studio 2010 Service Pack 1 will resolve this once it is released (see the heading Better platform support | Unit Testing on .NET 3.5 )

You can get the Beta version with a Go-Live licence now...

问题回答

You haven t suggested changing to a different test framework. Personally, I use NUnit and have for years. It s far more sophisticated that the stuff in 2008. I haven t had time to see what s changed in 2010 but I can t see MS catching up that quickly.





相关问题
run unit tests and coverage in certain python structure

I have some funny noob problem. I try to run unit tests from commandline: H:PROpyEstimator>python src estpython est_power_estimator.py Traceback (most recent call last): File "src est...

How to unit-test an enterprise symfony project?

I´m working on a huge project at my work. We have about 200 database tables, accordingly a huge number of Models, Actions and so on. How should I begin to write tests for this? My biggest problem ...

Code Coverage Tools & Visual Studio 2008 Pro

Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...

Unit testing. File structure

I have a C++ legacy codebase with 10-15 applications, all sharing several components. While setting up unittests for both shared components and for applications themselves, I was wondering if there ...

Unit Testing .NET 3.5 projects using MStest in VS2010

There s a bug/feature in Visual Studio 2010 where you can t create a unit test project with the 2.0 CLR. https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=483891&wa=...

Unit Test for Exceptions Message

Is there a simple (Attribute-driven) way to have the following test fail on the message of the exception. [TestMethod()] [ExpectedException(typeof(ArgumentException))] public void ExceptionTestTest() ...

热门标签