使用 Pex 和 Moles 进行非 PUT 测试
我想使用 .NET 4 测试一些未针对 TDD 或任何其他形式的自动化测试编写的代码。VS2010
中的集成单元测试不足以实现我的目标,所以我查看了 Pex & ;鼹鼠。
我拥有的是用于表示远程设备上的视频文件的代码。对设备的访问是通过特定的 SDK 处理的,并为该 SDK 编写了一个包装器。使用 Moles,我可以重写包装器函数,并将它们替换为从本地文件读取数据的函数。我使用 Moles 和集成单元测试来做到这一点。然而,这还不够,因为我只能以这种方式模仿“始终工作”的设备,而实际上,它们确实经常失败。
我考虑过将 PexChoose 添加到假方法的主体中,以便它们要么正常工作,要么失败,这样 Pex 就会构建一个各种方法执行结果的可能组合树。
但是,如果我尝试从现有代码创建 Pex 测试,从测试中删除所有参数(我不需要它们,所有内容都安排在里面),添加模拟方法并尝试运行 Pex Explorations,它会导致“路径超出范围”消息。我尝试过设置非常高的界限,但没有帮助。我能做什么来解决这个问题?
我对 Moles、Pex 和一般的单元测试非常陌生,所以我在概念上可能是错误的。提前致谢。
I want to test some code that isn't written with regards to TDD or any other form of automated testing, using .NET 4.
The integrated Unit Testing in VS2010 isn't enough for my goals, so I've looked at Pex & Moles.
What I have is a code that is used to represent video files on a remote device. Access to the device is handled via a specific SDK, and a wrapper is written for that SDK. Using Moles, I can override the wrapper functions and substitute them with functions that read data from local file. I do that using Moles and integrated unit testing. However, it's not enough, as I can only imitate "always working" device that way, while in reality, they do often fail.
I've thought about adding PexChoose into bodies of fake methods, so that they either work as they should or fail, so that Pex would build a tree of possible combinations of various methods' execution outcomes.
However, If I try to create a Pex test from existing code, removing all parameters from the test( I don't need them, everything gets arranged inside), add the mock methods and try to run Pex Explorations, it results in "path bounds exceeded" message. I have tried setting very high bounds, but it didn't help. What can I do to solve this?
I'm very new to Moles, Pex, and unit testing in general, so I may be conceptually wrong. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您尝试测试您的应用程序如何响应 SDK 中发生的故障(由于磁盘或其他原因),那么没有什么可以阻止您在委托中抛出异常。
If you are attempting to test how your application responds to a failure that occurs within the SDK (due to disk or whatever), there isn't anything stopping you from throwing exceptions in your delegates.
对我有用。
以下是 pex 探索结果:http://xmages。净/存储/10/1/0/c/e/upload/c6c9ced6.png
Works for me.
Here are the pex exploration results: http://xmages.net/storage/10/1/0/c/e/upload/c6c9ced6.png