ruby 黄瓜/水豚 vs 硒?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11349369/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 05:15:31  来源:igfitidea点击:

Cucumber/Capybara vs Selenium?

rubyseleniumcucumbercapybara

提问by treaz

The other day I was showing one of the testers at my company some tests I had written in cucumber (2 features, 5 scenarios). Then he asked me question that I could not answer:

前几天,我向我公司的一位测试人员展示了我用 Cucumber 编写的一些测试(2 个功能,5 个场景)。然后他问了我一个我无法回答的问题:

How is this better than selenium or any other functionality test recording tool?

这比 selenium 或任何其他功能测试记录工具好在哪里?

I understand that cucumber is a different technology and it's placed at a different level of testing, but I can't understand why I should bother to write and maintain Cucumber/Capybara tests.

我知道黄瓜是一种不同的技术,它被置于不同的测试级别,但我不明白为什么我要费心编写和维护 Cucumber/Capybara 测试。

Can someone give me a reasonable explanation for using Cucumber/Capybara instead of just Selenium?

有人能给我一个合理的解释,使用 Cucumber/Capybara 而不是 Selenium 吗?

采纳答案by Doug Noel

This question is borderline asking for an opinion. Your question actually reads to me, "What tool is right for me?" I say this because you don't give a reason for why you chose Cucumber and Capybara. I believe to answer that tester's question, you need to answer a couple more questions first:

这个问题是边缘性的征求意见。你的问题实际上是在告诉我,“什么工具适合我?” 我这样说是因为你没有给出你选择黄瓜和水豚的理由。我相信要回答该测试人员的问题,您需要先回答几个问题:

1.) What stage in the process are you going to be writing these tests?

1.) 您将在流程的哪个阶段编写这些测试?

Cucumber may not be the right choice for unit tests, depending on the language you're using. But it can be used for any level of testing, from unit to integration to end-user.

Cucumber 可能不是单元测试的正确选择,这取决于您使用的语言。但它可以用于任何级别的测试,从单元到集成再到最终用户。

2.) Who is going to maintaining your tests? You? Other developers? Testers? Business Analysts? Project Managers?

2.) 谁来维护你的测试?你?其他开发商?测试员?商业分析师?项目经理?

Automated tests must be maintained, and knowing who will be doing that can help you decide on a tool - as some will be too technical for certain users.

必须维护自动化测试,并且知道谁将执行该测试可以帮助您决定工具 - 因为某些工具对于某些用户来说技术性太强。

3.) Who is going to be defining new tests?

3.) 谁来定义新的测试?

Cucumber is meant to be used collaboratively between development, QA and business owners. It is the perfect tool for leveraging everyone's knowledge into the automated testing process. It requires the development of an ubiquitous language to be effect however. You can read up on that on James Shore's Art of Agilepage.

Cucumber 旨在在开发、QA 和业务所有者之间协作使用。它是将每个人的知识用于自动化测试过程的完美工具。然而,它需要开发一种无处不在的语言才能生效。您可以在James Shore 的 Art of Agile页面上阅读相关内容。

Once you've answered these questions, you're ready to address the tester's question.

回答完这些问题后,您就可以回答测试人员的问题了。

However, there are a couple of points to keep in mind when comparing recording tools (such as Selenium IDE, HP Quick Test Pro, IBM Rational Functional Tester) vs. development tools (nUnit, jUnit, RSpec, Selenium webdriver, Capybara) is that they are targeted towards different audiences. They also have different plusses and minuses.

但是,在比较记录工具(例如 Selenium IDE、HP Quick Test Pro、IBM Rational Functional Tester)与开发工具(nUnit、jUnit、RSpec、Selenium webdriver、Capybara)时,有几点需要牢记:它们针对不同的受众。它们也有不同的优点和缺点。

Recording tools are easy for anyone to use, but the scripts they create are fragile. They break easily and require more maintenance. They are great for one-off automated testing, where you need to get it done quickly and have non-technical manpower.

任何人都可以轻松使用录制工具,但它们创建的脚本很脆弱。它们很容易损坏,需要更多的维护。它们非常适合一次性自动化测试,您需要快速完成并拥有非技术人力。

Development tools have a larger learning curve and require programming (or at the least scripting) experience. The scripts are generally more robust, but require more technical knowledge to maintain. They are a good solution when you want repeatability and plan to use tests for a long time.

开发工具具有更大的学习曲线,需要编程(或至少脚本)经验。脚本通常更健壮,但需要更多的技术知识来维护。当您想要可重复性并计划长时间使用测试时,它们是一个很好的解决方案。

I strongly suggest you read The Cucumber Book. It will really help you decide if Cucumber is the right choice for you.

我强烈建议你阅读黄瓜书。它将真正帮助您确定 Cucumber 是否是您的正确选择。

回答by Andrei Botalov

Cucumber isn't only a testing tool. Besides testing Cucumber features also take a role of documentation, a mechanism to collaborate with stakeholders and requirements storage (if you write them in declarative style).

Cucumber 不仅仅是一种测试工具。除了测试 Cucumber 功能之外,还充当文档的角色,这是一种与利益相关者和需求存储协作的机制(如果您以声明式的方式编写它们)。

You don't have to use Cucumber with Capybara. You can use selenium directly. But Capybara has the same high-level API for all supporting drivers. It's more high-level than Selenium's and allows to write tests a bit faster. You don't have to change code when you switch from one driver to another.

您不必将 Cucumber 与 Capybara 一起使用。您可以直接使用硒。但是 Capybara 对所有支持的驱动程序都有相同的高级 API 。它比 Selenium 更高级,并且可以更快地编写测试。当您从一个驱动程序切换到另一个驱动程序时,您不必更改代码。

Tests built using test recording tools are generally much worse. Selenium IDE may produce valid programming code but it's not good-looking and thus quiet difficult to maintain.

使用测试记录工具构建的测试通常要糟糕得多。Selenium IDE 可能会产生有效的编程代码,但它不好看,因此很难维护。

回答by gerky

Cucumber is tool used to make tests readable to business users. It consists of plain English sentences that are matched using regex to your Capybara steps.

Cucumber 是用于使测试对业务用户可读的工具。它由简单的英语句子组成,这些句子使用正则表达式与您的 Capybara 步骤匹配。

Using recording tools won't do you any good in the long run. They were meant for beginners and aren't that powerful so I recommend you go straight to coding.

从长远来看,使用录音工具对您没有任何好处。它们是为初学者设计的,功能不是很强大,因此我建议您直接进行编码。

You can use Selenium alone for your tests, but I would recommend you continue to use Cucumber for documentation purposes, if you find them useful and easy to work with. After all, Cucumber can use Capybara or the Selenium web driver.

您可以单独使用 Selenium 进行测试,但如果您发现它们有用且易于使用,我建议您继续将 Cucumber 用于文档目的。毕竟,Cucumber 可以使用 Capybara 或 Selenium Web 驱动程序。

回答by Sam G

Selenium ide is good for testing features that have mostly visual elements (links, text and etc.). But often web apps have features that don't represent itself as visual elements, like sending emails, queueing jobs, communicating with 3rd party services and etc. You could, for example, test if an 'Email has been sent' message is present after submitting a form. But it doesn't really tell you if an email is actually sent and therefore you aren't really testing the whole feature here.

Selenium ide 适用于测试主要具有视觉元素(链接、文本等)的功能。但 Web 应用程序通常具有不将自身表现为视觉元素的功能,例如发送电子邮件、排队作业、与 3rd 方服务通信等。例如,您可以测试是否存在“电子邮件已发送”消息提交表格。但它并没有真正告诉您是否真的发送了电子邮件,因此您并没有真正在这里测试整个功能。