Selenium、Nunit 最佳实践?

发布于 2024-09-28 05:29:03 字数 527 浏览 1 评论 0原文

我想了解更多有关如何使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

拔了角的鹿 2024-10-05 05:29:03

我已经为您回答了下面的每个问题。

  1. 测试不应该关心它们运行的​​顺序。如果您开始担心,您将开始引入测试的不稳定。如果您必须在每次测试时登录,请这样做,如果您需要在测试期间注册多个用户,请这样做。测试应该始终能够自行运行。

  2. Nunit 将其结果记录在 XML 文件中。这将有一个通过和失败的列表,并且通常由几乎所有连续

  3. 以漂亮的方式呈现,请参阅我的答案 模块化 Selenium RC 测试脚本的最佳实践

    • 测试应始终有一个已知的起点。在 Selenium 的上下文中,这可能意味着打开某个页面来启动工作流程。
    • 测试不应依赖于任何其他测试来运行。如果测试要添加某些内容,则无需单独的测试来删除它。这是为了确保如果在一次测试中出现问题,并不意味着您需要检查很多不必要的失败。
    • 测试一次只能测试一件事。
    • 测试应该自行清理。

I have answered each of the questions for you below.

  1. 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.

  2. 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

  3. See my answer for Best Practices for modularizing Selenium RC test scripts

    • Tests should always have a known starting point. In the context of Selenium this could mean opening a certain page to start a workflow.
    • Tests should not have to rely on any other tests to run. If a test is going to add something do not have a separate test to delete it. This is to ensure that if something goes wrong in one test it will not mean you have a lot of unnecessary failures to check.
    • Tests should only test one thing at a time.
    • Tests should clean up after themselves.
绝影如岚 2024-10-05 05:29:03

如果您希望使用 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.

海风掠过北极光 2024-10-05 05:29:03

我刚刚经历过这个。在模块化和有用的工具方面。我认为更多地考虑构建一个敏捷的、维护良好的自动化 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文