在VS2010使用MSTest的单元测试.NET 3.5的项目 [英] Unit Testing .NET 3.5 projects using MStest in VS2010

查看:191
本文介绍了在VS2010使用MSTest的单元测试.NET 3.5的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有在Visual Studio 2010中的错误/功能,您不能创建一个单元测试项目与2.0 CLR。​​

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

<一个href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=483891&wa=wsignin1.0" rel="nofollow">https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=483891&wa=wsignin1.0

这会导致各种各样的,当被测试的项目目标定位在2.0 CLR(ASP.NET MVC 2的.NET 3.5 SP1前在这种情况下)的问题 - 在调试崩溃测试意外失败,在一种情况下测试因为的System.Web 2.0.0.0依赖这不是在项目目标定位4.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.

这是无法改变的测试项目为目标的3.5框架。

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)升级整体解决方案,以面向.NET 4
我想主办Azure和目前还不清楚在这一点上,如果/当对.NET 4.0的支持将增加。请参阅<一href="http://stackoverflow.com/questions/1679426/net-4-0-on-windows-azure">http://stackoverflow.com/questions/1679426/net-4-0-on-windows-azure

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 http://stackoverflow.com/questions/1679426/net-4-0-on-windows-azure

2)滚动整个项目回Visual Studio 2008的
这也是不得已而为之,因为有一些特点,2010年,我真的想用

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)构建单元测试在2008年和管理的参考手动
这将工作,但是这将是一个巨大的痛苦。

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

任何想法?

推荐答案

它看起来像Visual Studio 2010 Service Pack 1的<一个href="http://blogs.msdn.com/b/jasonz/archive/2010/12/07/announcing-visual-studio-2010-service-pack-1-beta.aspx"一旦它被释放相对=nofollow>将解决此(见标题更好的平台支持|单元测试的.NET 3.5')

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')

您可以得到Beta版与go-live许可,现在...

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

这篇关于在VS2010使用MSTest的单元测试.NET 3.5的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆