测试复杂的自定义 WinForms 控件
我正在开发相当复杂的 .NET 自定义控件(40K 行代码),但在测试它时遇到了一些麻烦。
我已经完成了几个示例项目,展示了控件的主要功能,但只能测试控件状态和操作的一小部分。
由于以下问题,单元测试也是无用的:
- 大量的用例(例如,描述“项目选择”可能需要大约 4 页的规范)
- 做同样事情的多种方法(也来自用户代码或 GUI)
- 控制有许多状态和子状态,并且任何东西都可能无法在每个状态下工作
- 如何测试设计时支持?
我知道这是GUI测试的一个常见问题,所以我想问一下您是否有任何成熟的测试自定义可视化组件的实践?
感谢您的任何建议。
I am developing quite complex .NET custom control (40K lines of code) but have some trouble testing it.
I have done several sample projects demonstrating main features of the control, but one can test only small subset of control states and operations.
Unit tests are also useless, because of these problems:
- tremendous number of use cases (e.g. describing "item selections" can take some 4 pages of specs)
- many ways of doing the same thing (and also from user-code or GUI)
- the control have many states a sub-states, and anything may not possibly work in every state
- how to test design-time support?
I know this is a common problem of GUI testing, so I would like to ask you if there are any well-estabilished practices of testing custom visual components?
Thanks for any advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最主要的是将 GUI 测试限制在最低限度,因为这是最昂贵的测试方式。在 40K 行代码中,我敢打赌 90% 的代码根本不能真正与 WinForm GUI 元素一起工作。因此,大部分内容可以通过单元测试来覆盖,但这取决于您构建代码的方式。
需要考虑的事情:
我从事相对复杂的 WinForms 应用程序,这些模式从未让我失望过。
至于 GUI 测试,我使用 UI Automation,但仅适用于某些标准案例。其他一切都由非 GUI 单元测试涵盖。
The main thing is to limit the GUI testing to a minimum, because it's the most expensive way to test. In 40K lines of code I bet 90% of code doesn't really work with the WinForm GUI elements at all. So most of it could be covered by unit tests, but this depends on the way you structured your code.
Things to consider:
I work on a relatively complex WinForms application and these patterns have never failed me.
As for GUI testing, I use UI Automation, but only for some standard cases. Everything else is covered by non-GUI unit testing.