如何针对 Windows Azure SDK v1.4 运行编码的 UI 测试
我有一个 MVC3 Web 应用程序,它已经发展到我想开始自动化一些功能测试的程度。因此,我一直在尝试将编码的 UI 测试添加到我放入单元测试的同一项目中。除了沮丧,什么也没有。
我已经能够记录一系列简单的步骤:登录应用程序。
我能够生成代码,并且可以在名为 UIMap.Designer.cs 的文件中看到生成的代码。该类的实例被实例化,并在我命名为 LoginTest.cs 的文件中调用测试方法。
当我尝试右键单击 LoginTest.cs 中的 [TestMethod] 并选择“运行测试”时,我最初收到以下错误:
无法加载测试容器“C:...\WebRole.Tests.dll”或其依赖项之一。错误详细信息:System.IO.FileNotFoundException:无法加载文件或程序集“Microsoft.VisualStudio.TestTools.UITesting,Version=10.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一。系统找不到指定的文件。
因此,我将以下引用从 Copy Local = false 翻转为 true:
- Microsoft.VisualStudio.TestTools.UITesting
- Microsoft.VisualStudio.TestTools.UITest.Extension
- Microsoft.VisualStudio.QualityTools.CodedUITestFramework
现在,当我运行测试时,我得到以下内容输出:
测试开始:
测试总数:1,已过滤:1
未找到测试。
持续时间:94.9989452249951
浏览器实例未启动。 Azure 计算模拟器和 Azure 存储模拟器均未启动。该应用程序未打包和部署。简而言之,当我运行应用程序时发生的所有事情似乎都没有发生。因此,我对 UI 测试如何运行感到困惑,因为 Azure 模拟器环境未运行。
为了解决这个问题,我尝试打开两个 VS2010 实例。首先,我像往常一样运行应用程序以运行 Azure 模拟器并部署应用程序。在第二个中,我运行了 CodedUITest 方法。结果相同。
现在,我被困住了。其他人是否能够针对 Azure SDK v1.4 提供的 Azure 模拟器运行编码的 UI 测试?
I have an MVC3 web application that has grown to the point I want to start automating some of the functional testing. So, I've been trying to add a Coded UI Test to the same project that I put unit tests into. Nothing but frustration.
I have been able to record a simple series of steps: logging into the application.
I was able to generate the code and I can see the generated code in a file named UIMap.Designer.cs. An instance of this class is instantiated and the test method is called in a file I named LoginTest.cs.
When I try to right-click on the [TestMethod] in LoginTest.cs and choose Run Test, I was initially getting the following error:
Unable to load the test container 'C:...\WebRole.Tests.dll' or one of its dependencies. Error details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
So, I flipped the following References from Copy Local = false to true:
- Microsoft.VisualStudio.TestTools.UITesting
- Microsoft.VisualStudio.TestTools.UITest.Extension
- Microsoft.VisualStudio.QualityTools.CodedUITestFramework
Now, when I run the test, I get the following output:
Testing started:
Total tests: 1, filtered: 1
No tests found.
Duration : 94.9989452249951
A browser instance isn't started. Neither the Azure Compute nor the Azure Storage emulators are started. The application isn't packaged and deployed. In short, none of the things that happen when I run the application seem to happen. So, I'm puzzled about how the UI Test could run at all, since the Azure emulator environment isn't running.
To work around this, I tried opening two instances of VS2010. In the first, I ran the application as usual to get the Azure emulators running and the application deployed. In the second, I ran the CodedUITest method. Same results.
Now, I'm stuck. Is anybody else able to run a Coded UI Test against the Azure emulators provided with Azure SDK v1.4?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这对于OP来说可能太晚了,但可能会帮助其他遇到类似问题的人(几个小时前就是我)。
警告:我是 CodedUI 的新手,因此这可能不是执行此操作的正确方法。但至少它让我开始了。
我也遇到过类似的情况:Azure 1.4,ASP.NET MVC(在我的例子中是 2)Web 应用程序。我想启动一套可以在桌面开发环境 (VS2010 Premium) 中运行的 UI 测试。
以下是让我开始的步骤:
1. 记录一些 CodedUI 测试 - 这样您就可以看到正在运行的东西,以证明您能够做到这一点。 (我按照以下步骤执行了前几个步骤: http://msdn.microsoft.com /en-us/library/dd286608.aspx)。
在开始录制之前打开浏览器并记录启动 Web 应用程序所需执行的所有操作。
在您的编码 UI 测试类中,添加带有 [TestInitialize] 属性的方法:
当然,您的 URI 可能会有所不同。这是我从其他帖子中推断出的一点魔力。将 TestInitialize 放在折叠的代码区域中并没有帮助。
要运行测试,请启动 Azure 模拟器:Ctrl+F5(这将在浏览器中启动 Web 应用程序,但不运行测试。
您现在可以从启动模拟器的 VS 实例运行测试。
This is probably way too late for the OP, but may help someone else with a similar issue (that was me a couple of hours ago).
Caveat: I'm a complete newbie with CodedUI, so this may not be the right way to do this. But at least it got me started.
I've got a similar situation: Azure 1.4, ASP.NET MVC (2 in my case) web app. I want to start a suite of UI tests that I can run in my desktop development environment (VS2010 Premium).
Here are the steps that got me started:
1. Record a bit of a CodedUI test - just so you'll have something to see running to prove that you are able to do this. (I followed the first few steps from this: http://msdn.microsoft.com/en-us/library/dd286608.aspx).
Open the browser before you start recording and record everything you need to do to start your web app.
In your Coded UI test class, add a method with a [TestInitialize] attribute:
Your URI may, of course, vary. This was the bit of magic I had to infer from some other posts. Having TestInitialize in a collapsed code region didn't help.
To run the tests, start the Azure emulators: Ctrl+F5 (which will start the web app in a browser, but not running the test.
You can now run the test from the same instance of VS that you started the emulators from.
您所经历的痛苦不仅与Azure有关,而且与整个编码UI测试有关。对于 MVC(和 asp.net),有一些工具可以减轻痛苦(并且您不需要编码的 ui 套件)。
您尝试过 SpecFlow 和 WatiN< /a>?甚至还有一个可以从 Nuget 使用的包,它是作为 MVCContrib 库的一部分构建的。
希望它能帮助您测试 UI。
查看channel9以获取一些说明,例如: 此视频
the pain you are experiencing is not only related to Azure, but to coded UI test as a whole IMHO. for MVC (and asp.net) there are a couple of tools that could ease the pain (and you'll not need the coded ui suite).
did you try SpecFlow and WatiN? there is even a package you can use from Nuget that is build as part of the MVCContrib library.
hope it will help you to test the UI.
checkout channel9 for some instructions like: this video