TDD适用于Windows Store应用开发而无需模拟 [英] TDD for Windows Store app development without mocks

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

问题描述

有人为Windows Store App开发提供了一个良好的TDD设置吗?我已经习惯了使用模拟框架,但这已不再是一个选择,因为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(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 Store App开发的好的技术吗?如果是这样,您做了什么?

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"单元测试项目中没有添加假货程序集"选项,因此也许不是一个选择.

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程序集中,以使其可以使用普通单元通过模拟进行单元测试.测试项目.然后,在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.

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

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