Windows 7 Phone 代码的单元测试有什么我应该知道的问题吗? [英] Are there any issues I should know about with unit test of Windows 7 Phone code?

查看:30
本文介绍了Windows 7 Phone 代码的单元测试有什么我应该知道的问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我假设代码是标准的 C#,我可以只使用 nUnit、TestDriven.net 等.

I am assuming that as the code is standard C#, I can just use nUnit, TestDriven.net etc.

我错过了什么吗?

其他人试图这样做时遇到了什么陷阱"?

What "traps" have other people hit trying to do this?

推荐答案

如果您要在基于 Silverlight 的项目中测试 C# 代码,则需要采取一些步骤才能使用诸如 nUnit 之类的框架.Silverlight 项目中的 C# 代码将根据 Silverlight 框架二进制文件进行编译,因此 nUnit 的二进制文件将无法按原样运行,因为它们是根据标准 .NET 框架编译的.

If you are talking about testing C# code in a Silverlight-based project, then there are some steps that need to be taken in order to use frameworks such as nUnit. The C# code in a Silverlight project will compile against the Silverlight framework binaries, so the binaries for nUnit won't work as-is since they are compiled against the standard .NET framework.

如果您想使用 nUnit,您可以设置一个常规的 C# 类库并将您的 Silverlight C# 文件引用到这个项目中.您想将它们添加为链接,详情此处.根据个人经验,这可能会有点疯狂,因为您的文件在两个地方链接,并且链接文件的能力是有限的(如果您的 Silverlight C# 代码引用了任何特定于 Silverlight 的二进制文件,则无法执行此链接技巧).

If you want to use nUnit, you can setup a regular C# class library and reference your Silverlight C# files into this project. You want to add them as a link, which is detailed here. From personal experience, this can get a little crazy because your file is linked in two places and the ability to link over the files are limited (if your Silverlight C# code references any Silverlight-specific binaries, you cannot perform this linking trick).

另一种选择是使用 Silverlight 单元测试框架,可以找到其二进制文件 这里.这与 Silverlight Toolkit 中的 Silverlight 单元测试器非常相似,不同之处在于它作为手机应用在手机上运行.

The other option is to use the Silverlight Unit Test Framework, the binaries for which can be found here. This works much like the Silverlight unit tester in the Silverlight Toolkit, except that it runs on the phone as a phone app.

这篇关于Windows 7 Phone 代码的单元测试有什么我应该知道的问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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