问题描述
您好,我正在考虑使用编码 UI 测试 (CUIT) 来测试应用程序.我已经尝试过录制选项,但这对我来说不够灵活.如果您在不同尺寸的屏幕上使用它,它会损坏.
Hi I am looking at using Coded UI Tests (CUIT) to test an application. I have tried the recording option and this is not flexible enough for me. If you use it on a different size screen it breaks.
我知道您可以手动编写测试代码,但我找不到任何关于如何编写基本测试的好示例.这里有一些使用 CUIT 的示例,但这些帖子来自 2011 年,我不确定它们与 Microsoft 对 CUIT 的新升级有多大的相关性.
I know you can hand code the tests but I cannot find any good examples of how to write a basic test. There are examples on here that use CUITe but these posts are from 2011 and I'm not sure how relevant they are anymore with the new upgrades to CUIT from Microsoft.
这些测试需要与我在 Visual Studio 2012 Ultimate 中的构建环境集成,这就是我不使用 Selenium 的原因.
These tests need to be integrated with my build environments in Visual Studio 2012 Ultimate, that is why I'm not using Selenium.
我们将不胜感激代码示例或指向优秀教程的链接,但特别是我正在寻找有关如何开始手动编码我的 CUIT 的示例
And Code samples or links to good tutorials would be appreciated, but in particular I am looking for an exampl on how to start hand coding my CUITs
推荐答案
CodePlex 上的 Code First 编码 UI 测试 API 项目 (http://codeduicodefirst.codeplex.com/) 包含一个可以下载的项目演示 - 应用程序和测试.它专为构建 CUIT 测试而设计,不依赖于记录/播放.
The Code First coded UI test API project on CodePlex (http://codeduicodefirst.codeplex.com/) includes a project demo that you can download - application and tests. It's designed for building CUIT tests without the dependency on record/playback.
如果您要在纯代码的基础上工作,您最需要的是一种避免依赖于 CUIT 记录创建的自动生成对象映射的方法.Code-First 项目使用映射到单个页面对象的类来解决这个问题 - 如果我没记错的话,您需要扩展项目代码以使用桌面应用程序.
The biggest thing that you need if you're going to work on a code-only basis is a way to avoid the dependency on the autogenerated object map the CUIT recordings create. The Code-First project uses classes mapped to individual page objects to work around this - you'd need to extend the project code to work with desktop applications if I remember correctly.
(我与这个项目没有任何关系——它只是我发现的除 CUITe 之外的唯一手工编码资源,而且 CUITe 有一段时间没有更新了,这是我最后一次看到的).
(I am not affiliated with this project in any way - it's just the only hand-coding resource other than CUITe that I've found, and CUITe hasn't been updated in a while, the last I saw).
这篇关于手工编码的 UI 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!