如何创建单元测试组件.NET可移植类库? [英] How do you create a unit test assembly for a .NET Portable Class Library?

查看:210
本文介绍了如何创建单元测试组件.NET可移植类库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图单元测试,我创建了一个可移植类库,我想,以确保它正在测试使用相同的框架子集,它的目标。

I am attempting to unit test a Portable Class Library that I've created and I want to make sure it's being tested with the same framework subset that it targets.

<一个href="http://blogs.msdn.com/b/visualstudioalm/archive/2012/06/18/visual-studio-2012-rc-what-s-new-in-unit-testing.aspx">Per在Visual Studio ALM + Team Foundation Server的博客,在MSTest的单元测试框架,转变为在Visual Studio 2012 RC一个PCL;但是,我无法创建一个可移植类库然后引用VS2012 RTM的MSTest的框架。

Per the Visual Studio ALM + Team Foundation Server blog, the MSTest unit test framework was converted to a PCL in Visual Studio 2012 RC; however, I am unable to create a portable class library and then reference the MSTest framework in VS2012 RTM.

  • 在浏览中的引用对话框中显示我没有单元测试组件注册为PCL兼容。
  • 添加在项目文件中手动GAC参考 Microsoft.VisualStudio.QualityTools.UnitTestFramework 产生参考未找到生成错误。
  • 添加一个手工装配直接参照 C:\ Program Files文件(x86)的\微软的Visual Studio 11.0\Common7\IDE\ReferenceAssemblies\v4.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll产生一个生成警告称UnitTestFramework集引用一个不兼容的的mscorlib 版本。
  • Browsing in the "References" dialog shows me that no unit testing components are registered as compatible with PCL.
  • Adding a manual GAC reference in the project file to Microsoft.VisualStudio.QualityTools.UnitTestFramework yields a reference not found build error.
  • Adding a manual direct assembly reference to C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ReferenceAssemblies\v4.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll yields a build warning saying the UnitTestFramework assembly references an incompatible mscorlib version.

我发现(感谢早期的答案),有一个项目类型单元测试库(Windows应用商店的应用程序)引用了不同的 MSTest的大会 C:\ Program Files文件(x86)的\微软SDKs\Windows\v8.0\ExtensionSDKs\MSTestFramework\11.0\References\CommonConfiguration\neutral\Microsoft.VisualStudio.TestPlatform.UnitTestFramework.dll.此项目类型创建一个小的无用户界面的Windows商店应用程序......完整的清单和一切。它也不会允许我指定框架我针对 - 它似乎对Windows应用商店的应用程序只有

I did find (thanks to an early answer) that there is a project type Unit Test Library (Windows Store apps) that references a different MSTest assembly at C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0\ExtensionSDKs\MSTestFramework\11.0\References\CommonConfiguration\neutral\Microsoft.VisualStudio.TestPlatform.UnitTestFramework.dll. This project type creates a small no-UI Windows Store app... complete with manifest and everything. It also doesn't allow me to specify which frameworks I'm targeting - it appears to be only for Windows Store apps.

潜在的故障的假设,我应该与单元测试组件针对同一个框架子集作为库所试验测试我的便携式类库项目...

Under the potentially faulty assumption that I should be testing my Portable Class Library projects with unit test assemblies that target the same framework subset as the library-under-test...

如何创建单元测试组件.NET可移植类库?

(我愿意接受其他框架也针对PCL,我只是目前尚不知情除了MSTest的其他解决方案,已经考虑到这一点。)

(I am open to other frameworks that also target PCL, I'm just currently unaware of other solutions besides MSTest that have taken this into account.)

推荐答案

的xUnit现在有PCL单元测试支持; http://xunit.github.io/

xUnit now has support for PCL unit testing; http://xunit.github.io/

这篇关于如何创建单元测试组件.NET可移植类库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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