Selenium、Nunit 最佳实践?
我想了解更多有关如何使用 Selenium IDE 和 RC 创建良好的自动化测试的信息。有没有人有兴趣分享信息。或讨论这个?特别是对于以下事情:
1)组织 UI 测试的好方法是什么?现在我正在通过 NUnit 执行这些测试,并且按测试名称的字母顺序执行测试。有没有更好的办法。 (我正在用 C# 而不是 java 编写 selenium 脚本)
2) 如何记录结果?
3) 模块化 Selenium RC 测试?我这里遇到问题了。由于我通过 NUnit 执行测试,所以我能想到的唯一方法是为测试提供 ID,以便它们以正确的顺序运行。另外,我还必须在 textfixture 类中一个接一个地编写所有测试。再说了,还有更好的办法吗?我尝试创建其他文件,但是当我在那里创建测试并选择它们在 NUnit 中运行时,看起来 selenium 服务器甚至没有启动。
4)自动化测试的最佳实践是什么?有任何网站/书籍/等的指针吗?
这些可能看起来很简单,但我花了几周的时间试图想出更好的方法,所以如果有人愿意提供建议或意见,我将非常感激!
谢谢!
I would like to learn more about how to use Selenium IDE and RC for creating good automation tests. Is there anybody who is interested in sharing info. or discussing this? Especially for things like:
1) What's a good way to organize the UI tests? Right now I am executing these tests thru NUnit and that executes the tests in the order of their alphabetical names. Is there a better way. (I am writing the selenium scripts in C# and not java)
2) How are the results logged?
3) Modularizing the Selenium RC tests? I am having a problem here. Since I am executing my tests thru NUnit, the only way I could figure was to give IDs to the tests so that they get run in the right order. Also I am having to write all my tests one after the other in the textfixture class. Again is there a better way? I tried creating additional files but when I create tests there and select them to run in NUnit, it looks like the selenium server doesn't even get started.
4) What are the best practices for automation testing? Any pointers to any sites/books/ etc.?
These might seem very simple things but I've spent weeks trying to come up with better ways, so if somebody is willing to offer suggestions or input I'll really appreciate it!
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经为您回答了下面的每个问题。
测试不应该关心它们运行的顺序。如果您开始担心,您将开始引入测试的不稳定。如果您必须在每次测试时登录,请这样做,如果您需要在测试期间注册多个用户,请这样做。测试应该始终能够自行运行。
Nunit 将其结果记录在 XML 文件中。这将有一个通过和失败的列表,并且通常由几乎所有连续
以漂亮的方式呈现,请参阅我的答案 模块化 Selenium RC 测试脚本的最佳实践
I have answered each of the questions for you below.
Tests shouldn't matter about the order that they run in. If you start worrying about that you are going to start introducing flakiness of tests. If you have to login with each test do so, if you need to register a number of users during your tests do so. Tests should always be able to run on their own.
Nunit logs its results in a XML file. This will have a list of the passes and fails and is normally rendered in a pretty fashion by nearly all Continuous
See my answer for Best Practices for modularizing Selenium RC test scripts
如果您希望使用 Selenium,那么我建议您使用 TestPlan 前端而不是其他语言。除了特定于领域的语言之外,它还提供良好的测试用例管理。您可以将测试组织成一个很好的层次结构,它将执行所有测试并报告结果。
它处理了启动 Selenium 的许多细节,并解决了 RC API 中的许多困难。
If your desires is to use Selenium then I can suggest instead use the TestPlan front-end instead of another language. In additional to a domain specific language it offers nice test case management. You can organize your tests into a nice hierarchy and it will execute all of them and report the results.
It takes care of a lot of details of launching Selenium and smooths over many difficulties in the RC API.
我刚刚经历过这个。在模块化和有用的工具方面。我认为更多地考虑构建一个敏捷的、维护良好的自动化 UI 测试框架比简单地模块化 selenium RC 脚本非常重要。 Selenium 2:测试工具初学者指南是一个很好的开始如何开始构建一个好的测试框架。在自动化测试框架运行失败 2-3 次之后,我在(页面对象模式)[https://code.google.com/p/selenium/wiki/PageObjects] 上取得了很大的成功。就过程而言,我发现最好从编写代码开始(您正在编写测试,因此测试应该很容易),但随着模式和结构开始建立,使用良好的 OOP 积极重构。我还推荐Google 如何测试软件来了解软件的动机一般来说,质量保证、组织层面的良好测试实践,以及何时和何时不使用自动化。
I've just went through this. In terms of modularizing and useful tools. I think it's really important to think more about building an agile, well maintained automated ui testing framework than simply modularizing selenium RC scripts. Selenium 2: Testing Tools Begginner's Guide was a great start for idea how to start building a good testing framework. I had MUCH success with the (Page Object pattern)[https://code.google.com/p/selenium/wiki/PageObjects] after failing 2-3 times getting an automated testing framework going. In terms of proccess, I found it best to start by writing code (you are writing tests, so it should be pretty easy to test), but aggressively refactoring using good OOP as patterns and structures begin to build up. I'd also reccommend How Google Tests Software for motivation of Software QA in general, good testing practices on an organizational level, and when and when not to use automation.