Resolving .NET Framework Conflicts with Test Projects

Visual Studio 2010

It is possible for your test project and the code under test to target different versions of the .NET Framework. This is not a problem if your test project targets .NET Framework 4. However, if your test project targets an earlier version of the .NET Framework than the code under test, your tests will not run.

If the test project does target an earlier version of .NET Framework, in order to run your tests you can either recreate the test project or change the target of the code under test. You cannot change the target of a test project.

NoteNote

Initially, it might seem that you can change the target of a test project.

For information about how to change the target of a code project, see How to: Target a Specific .NET Framework Version or Profile.

Upgrading a test project:

  • When you upgrade a Visual Basic MVC test project to Visual Studio 2010 you can choose to leave the target as it is, or you can upgrade it to .NET Framework 4. It is safest to upgrade it to .NET Framework 4, because .NET Framework 4 will run tests against code that targets earlier versions of .NET Framework.

  • When you upgrade any other test project in Visual Studio 2010 it automatically targets .NET Framework 4.

Creating a test project:

  • You can create Visual Basic test projects targeting any available .NET Framework.

  • Test projects created in other languages target .NET Framework 4.

Generating a test project:

  • If the code you are generating a test from is Visual Basic, the generated test project will target the same .NET Framework as the code you are testing. If the tests in your test project are generated from multiple code projects, all code projects must target the same .NET Framework.

  • All other generated projects will target .NET Framework 4.

Retargeting a test project:

  • After you upgrade, create, or generate a test project you cannot change the target .NET Framework.

Community Additions

ADD
Show: