Cucumber vs Junit(黄瓜 vs 朱尼特)
问题描述
我想问一下 Cucumber 和 JUnit 之间的实际区别是什么.我根本没有和 Cucumber 合作过.找到了一些文档,但我非常感谢曾与这两者合作过的人的一些反馈(对高 lvl 概述感兴趣).
I'd like to ask what's the practical difference between Cucumber and JUnit. I haven't worked with Cucumber at all; found some documentation but I'd greatly appreciate some feedback from someone who has worked with both (interested in a high lvl overview).
分解一下——我感兴趣的是什么(我将使用 Selenium 而不是 Protractor):
To break it down - what i'm interested in (I'll be using Selenium and not Protractor) :
- Cucumber 与 Junit 有什么不能做的事.
- 什么更容易使用(编码,编写测试的速度)?
- 两者都适用于页面对象?
我需要完成的一些事情
- 测试 CSS 样式
- 测试页面响应能力
- WebElements 上的标准操作(点击、获取数据等)
- 断言.
除此之外的任何内容都非常受欢迎.非常感谢您对此的回答,谢谢!
Anything in addition to this is more than welcomed. Greatly appreciate your answer on this, thank you!
推荐答案
JUnit 和 Cucumber 的目标不同.它们相互补充而不是相互替代.
JUnit and Cucumber are aiming at different goals. They are rather complement to each other than replace each other.
Cucumber 和 Junit 有什么不能做的事.
Are there any things that Cucumber can't do vs Junit.
您可以用 JUnit 做任何您不能用 Cucumber 做的事情.反之亦然.
There isn't anything you can do with JUnit that you can't do with Cucumber. And the other way around.
不同之处在于,JUnit 的目标是测试,而 Cucumber 的目标是与非技术人员协作.非技术人员不会理解单元测试的作用.但是,他们将能够理解并验证用 Gherkin 编写的示例.
The difference is that while JUnit aims at tests, Cucumber aims at collaboration with non technical people. Non technical people will not understand what a unit test does. They will, however, be able to understand and validate an example written in Gherkin.
什么更容易使用(编码,编写测试的速度)?
What's easier to use (coding, how fast you can write the tests) ?
使用 Cucumber 会产生更多开销.您必须将每个步骤作为一种方法来实现,而不仅仅是一个测试方法,就像使用 JUnit 时所做的那样.使用纯文本表达示例所获得的可读性有时值得付出额外的努力.
There is more overhead when you use Cucumber. You will have to implement each step as a method and not just one test method as you would do if you used JUnit. The readability you gain from expressing examples using plain text is sometimes worth the extra work.
两者都适用于页面对象?
Both work with Page Objects?
页面对象是您正在验证的网页的抽象.这是您作为开发人员/测试人员编写的课程.JUnit 和 Cucumber 都可以使用页面对象.事实上,从这个角度来看,工具之间没有区别.
Page Objects are an abstraction for the web page you are verifying. It is a class you write as developer/tester. The Page Objects can be used by both JUnit and Cucumber. In fact, there is no difference between the tools from that perspective.
选择使用 JUnit 还是 Cucumber 是粒度和受众的问题.
The choice to use JUnit or Cucumber is a matter of granularity and audience.
一个运作良好的工作流程是混合工具.定义应用程序应如何使用 BDD(Cucumber、Gherkin)工作的示例.使用 Cucumber 实现这些场景.然后,使用 JUnit 制定对高层业务利益相关者可能重要但不必要的细节.考虑一些重要但对利益相关者来说细节过多的极端案例.
A work flow that works well is to mix the tools. Define examples of how the application should work using BDD, (Cucumber, Gherkin). Implement these scenarios using Cucumber. Then, use JUnit to work out details that may be important but not necessary important for the business stakeholders at a high level. Think of corner cases that are important but are too much details for your stakeholders.
此处提供了描述这种组合的图片:https://cucumber.io/图片/home/bdd-cycle.png
An image that describes this mix is available here: https://cucumber.io/images/home/bdd-cycle.png
我不久前写了一篇博文,谈到了适合这项工作的工具:http://www.thinkcode.se/blog/2016/07/25/the-right-tool-for-the-job
I wrote blog post a while back where I talk about the right tool for the job: http://www.thinkcode.se/blog/2016/07/25/the-right-tool-for-the-job
正确的工具可能是 Cucumber.它也可以是 JUnit.这完全取决于您的观众.
The right tool may be Cucumber. It can also be JUnit. It all depends on your audience.
这篇关于黄瓜 vs 朱尼特的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:黄瓜 vs 朱尼特
基础教程推荐
- 如何强制对超级方法进行多态调用? 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01