简体   繁体   中英

Will Visual Studio 2010 only run 4.0 unit tests?

I have different projects written in .NET 3.5 and some unit test projects to cover them. When converting my solution to be used in Visual Studio 2010 I keep all my projects in 3.5 but the unit tests are forced to 4.0? This way I cannot use them with my regular projects anymore.

Resulting in this: Could not load file or assembly 'xxx.xxx.Core.UnitTest' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

So I can't unit test any project less then 4.0? Or am I doing something wrong here?

Currently the sad answer is yes - only tests created with VS2010 (.NET 4.0) are supported.

Apparently this one done on purpose - take a look at this "bug" report at Microsoft connect for details.

Update
after Microsoft's has seen the error of their way they have added .NET 3.5 unit tests support in VS2010 SP1 - the full details can be found in this post .

You can also re-target existing .NET 4.0 unit tests - How to re-target unit-tests to .Net Framework 3.5 in VS 2010 SP1

While test projects get converted to Visual Studio 2010 Test Project and compiled targeted for the .NET 4.0 framework luckily all the assemblies that you reference and test in your tests can still be .NET 3.5 (or whatever) assemblies. Anything else would be disastrous. But yes, you can no longer use Visual Studio 2008 to run those test projects.

A workaround, of course, would be to keep the source code for the tests, but have two different test projects, one for VS2008, and one for VS2010 using that same test source code. Cumbersome, but a working solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM