用于 Windows 应用商店应用程序开发的 TDD,无需模拟 [英] TDD for Windows Store app development without mocks

查看:22
本文介绍了用于 Windows 应用商店应用程序开发的 TDD,无需模拟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人想出一个好的 TDD 设置用于 Windows 应用商店应用程序开发?我已经习惯了使用模拟框架,但这不再是一种选择,因为 WinRT 中缺少动态程序集生成.

Has anyone come up with a good TDD setup for Windows Store App development? I'm so used to using mocking frameworks, but this is no-longer an option since dynamic assembly generation is missing in WinRT.

我已经看到了 alpha MoqRT 框架,但我希望在这样的实验阶段避免一些事情.我也很喜欢使用模拟对象,以至于我不愿意使用微软提供的存根或垫片作为替代品(Microsoft Fakes).

I have seen the alpha MoqRT framework, but I am hoping to avoid something in such experimental stages. I have also been so spoiled with using mock objects that I balk at using the stubs or shims offered as an alternative from Microsoft (Microsoft Fakes).

你们中是否有人成功地找到了使用 DI 和适当隔离的 TDD 样式单元测试进行 Windows 应用商店应用程序开发的好技术?如果有,你做了什么?

Have any of you successfully figured out good techniques for doing Windows Store App development using DI and properly-isolated TDD-style unit tests? If so, what have you done?

编辑:

我还注意到我的Windows Store App"单元测试项目中没有Add Fakes Assembly"选项,所以这可能不是一个选项.

I also notice that the "Add Fakes Assembly" option isn't present in my "Windows Store App" unit test project, so that maybe isn't an option.

推荐答案

我现在尝试的方法是将可测试的代码放在常规的 .NET 4.5 程序集中,允许使用普通单元使用 mock 对其进行单元测试测试项目.然后,在 Windows Store App 项目中,将这些相同的源文件添加为链接.这很不方便,因为我必须在两个平台之间复制项目引用,而且我必须小心确保代码在两个项目中都能编译,但这种方法确实让我可以使用更好的单元测试工具.

The approach I'm trying out now is placing the testable code in a regular .NET 4.5 assembly, allowing it to be unit tested with mocks using a normal unit test project. Then, in the Windows Store App project, these same source files are added as links. This is inconvenient since I'm having to duplicate project references between the two platforms, and I have to be careful to ensure the code compiles in both projects, but this approach does allow me to use better unit testing tools.

我仍然急切地等待着看看是否有人想出了更好的东西.

I'm still eagerly waiting to see if someone comes up with something better.

这篇关于用于 Windows 应用商店应用程序开发的 TDD,无需模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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