Cucumber+TestNG and Cucumber+JUNIT comparison - cucumber

Can anyone please help me in understanding what is difference or advantages of using Cucumber+TestNG over Cucumber+Junit ?

TestNG provides more Annotations Like #BeforeSuite .
TestNG it self provides support for Junit.
With Latest upgrade of cucumber(4.0) Cucumber - TestNg provides Parallel Execution at Scenario Level where as Junit provides at Feature level.

TestNG and Junit are just a unit testing frameworks, when you use Cucumber with Junit you can use Junit Annotation/Assertions in step definition file and similarly when you use Cucumber with TestNG you can use TestNG Annotation/Assertions in step definition file.

Actually in both cases you would be writing the Test Steps using selenium and probably will use the classes inside JUnit or TestNG to run the cucumber Feature file.
As per my knowledge the only place I used such file was the when I'm creating the TestRunner.java class.
It's much easier to do with JUnit since you just have to import org.junit.runner.RunWith But if you are using TestNG you'll need to use dataProviders and go on a bit more complex path to create the TestRunner Class
Other than that there won't be any other differences since you will be using cucumber features for testing.
Due to the above mentioned advantage, I recommend to use JUnit + Cucumber + Selenium for your scripting

I tried both but decided for JUNIT 4.12 (JUNIT 5 does not seem to work with cucumber yet). It has all that you need. But i have to test that parallel thing in Test NG i guess. ;)
I use Cucumber in a Spring Boot Project and therefore JUNIT did not cause any problems for me. I can hand over a browser instance over multiple classes here (#Autowired) and this makes my code so much more modularizable.
You may have more annotation-options with Test NG but somehow i have the feeling that more people work with JUnit, so you have more support and a bigger community here.

Related

What is the difference between Serenity BDD Framework and Cucumber tool

Today I've got some theoretical question. I have a little experience in BDD with Cucumber. Now I started working in API testing and I faced with Serenity BDD framework on my new project. It is used with Cucumber. So I would like to clarify what is the difference between Serenity BDD Framework and Cucumber and why can't we use just Cucumber for our tests, because it seems to me, like these two tools are doing the same job. Could anybody give me some explanation or maybe some link to correspondent documentation. Thanks in advance!
No, those are 2 different things.
Cucumber is the layer to map BDD syntax, which is written in .feature file, with actual code that does the job.
Serenity BDD is the framework supporting 3 different approaches:
Cucumber: same features as stand-alone cucumber, can work with UI or API Automation
Page Object: works with UI automation (selenium)
Screenplay: a design pattern for UI and API automation
Serenity BDD does many things for auto testers that:
Config-oriented: serenity.properties or serenity.conf. For example: take screenshot when FOR_EACH_ACTION, BEFORE_AND_AFTER_EACH_STEP, AFTER_EACH_STEP, FOR_FAILURES, DISABLED. This is really helpful for debugging. https://serenity-bdd.github.io/theserenitybook/latest/serenity-system-properties.html#_serenity_take_screenshots
Living report: much more better comparing to cucumber. https://serenity-bdd.github.io/theserenitybook/latest/living-documentation.html
Wrap other libs in nice and clean APIs: serenity-appium, serenity-browserstack, serenity-cucumber, serenity-rest-assured, serenity-saucelabs, serenity-shutterbug1x ... You see all of them at https://github.com/serenity-bdd/serenity-core

Why do we use JUnit with Cucumber rather using TestNg

I can see in many cases that people prefer Junit rather than TestNg when they are integrated with the cucumber framework but I never understand the reason and benefit of using JUnit over TestNG.
If anyone knows the exact reason please help me to understand. Also, most of the tutorial videos are using Junit.

What is the difference between Cucumber and QAF BDD2

What is the difference between Cucumber and QAF bdd, What are the features which QAF has which is not available in Cucumber and what are the features which are available in Cucumber and not available in QAF Bdd.
Let's first take a look at BDD2 and Gherkin syntax:
Gherkin is syntax that cucumber (and QAF as well) understands. BDD2 is superset of Gherkin syntax. That means BDD2 supports all gherkin keywords and structure and have additional provisions. Below are addition provision in BDD2 syntax:
Metadata support
Provision to have external data file for examples
Parameter support
Below scenario authored in BDD2:
#smoke #TestcaseId:12345
Scenario: A scenario is a collection of executable steps of different type
Given step represents a precondition to an event
When step represents the occurrence of the event
Then step represents the outcome of the event
See more examples of BDD2.
BDD2 looks like Gherkin and any gherkin editor can understands it as well. But it depends on runner to understand and use additional features. You can use BDD2 either with QAF or Cucumber. When using cucumber QAF-Cucumber will enable cucumber runner to get benefit of addition syntax feature.
Now let's take look on features of Cucumber and QAF.
Both are open source frameworks. Cucumber is more popular and well known while QAF is widely used by different enterprises but not as much popular as compared to cucumber.
Cucumber is dedicated for BDD implementation using Gherkin.
Where as QAF supports coded, keyword driven and BDD implementation using TestNG. QAF supports QAF BDD and advance QAF BDD2 syntax in addition to Gherkin.
Till cucumber 4, java implementation of cucumber was not thread-safe
but with cucumber-4 entire architecture of implementation get changed
and it started supporting parallel execution with thread safety.
QAF formally known as ISFW was thread safe from beginning and supports scenario level parallel execution.
Cucumber is Gherkin runner can be used with Junit, TestNG or standalone. Supports only gherkin syntax. Cucumber can run BDD2 QAF-Cucumber
QAF is Built upon TestNG and have native TestNG implementation for BDD. You can use cucumber runner by using QAF-Cucumber
Cucumber doesn't have inbuilt implementation for testing of
web,mobile, web-service. Either you need to write your own implementation or use third party framework that supports cucumber.
using cucumber for different black box testing needs.
QAF has inbuilt Web, Mobile, WebServices support with different
design concepts along with resource and test data management, integration with third party tools (like jira, ALM, QMetry, Rally etc).
Cucumber supports for different programing languages.
QAF is Java only.
Cucumber supports data-driven testing by use of Examples in gherkin
syntax.
QAF supports data-driven testing by use of Examples in Gherkin
or BDD2 syntax. It also supports External data providers and
data-provider interceptor.
Cucumber has hooks for scenario lifecyle.
QAF has support for all TestNG listeners with additional step listener. In addition to that it has support for webdriver listener, webelement listener, result updator and data-provider interceptor.
Till cucumber 4, Step implementation was required to use regular
expressions. With Cucumber 4 new way similar to QAF available to get
rid of regular expression in step definition.
QAF uses simple and easy way to provide description of step.
Cucumber have predefined Parameter Type support as method arguments. It also supports custom types. For any custom type you need to implement and configure type registry. User need to use defined parameter types in step definition.
QAF natively supports all complex types including Map, List, and any custom classes. It also has transformation support to customize parameter transformation behavior. In step description user is free to use meaningful name for parameter placeholder regardless of method argument type.
Cucumber doesn't support step definition in BDD.
QAF supports new step definition in BDD as well

what is the difference between io.cucumber and info.cukes

I am trying to integrate BDD using Cucumber. But I am really confused what is the difference between io.cucumber and info.cukes libraries. And which one to use and when.
I tried to read and understand the github README.md file still can't make heads or tails.
Still further I am not sure what is cucumber-jvm. Why do we need cucumber-junit (can't the standalone junit library suffice).
Thanks in advance. Any help is much appreciated.
Refer to the release notes for more details. - https://github.com/cucumber/cucumber-jvm/blob/master/CHANGELOG.md.
There has been substantial changes in cucumber 2. Refer to this for more - https://cucumber.io/blog/2017/08/29/announcing-cucumber-jvm-2-0-0
io.cucumber and info.cukes are Maven group ids. info.cukes was for Cucumber version till 1.2.5. The latest version are in io.cucumber starting from 2.0.0. There is also a new version 3 with more goodies in github with the master as mentioned in the release notes.
The reason the groupid was changed because gherkin has changed the groupid similarly.
cucumber-jvm is the java implementation of Cucumber framework. there are many other implementations in other languages - https://github.com/cucumber.
When you use the #RunWith(Cucumber.class) on top of the test class, it means that a specialized runner is being used which will execute the feature files. The default runner of junit will not get you anywhere, though might cough up some exceptions.

Executing cucumber (gherkin scripts) with SOAP UI ?

I'm trying to find possibilities for the BDD approach of testing my web services with SOAP UI & Cucumber. Is there any way to achieve this ? Please advise
Thanks
Exactly, both SOAPUI and Cucumber are different test runners. You have to choose between both. Except that SOAPUI provides you http-clients for calling services and Cucumber can contain any tests that use different libraries/clients to do different type of testing.
Presuming that you are thinking to use SoapUI just as http-client for services testing, its better to use Jersey client and use Cucumber/JBehave as BDD runner.
I Do Agree with #I Am's answer. Using Jersey or other httpclient do the needful. In case of jersy with BDD you can use QAF with Web service plugin. You can use cucumber gherkin or QAF BDD or pure java for test authoring. QAF bdd for web-service may look like below:
SCENARIO: My Fist webservice call
META-DATA: {"description":"Just for learning purpose"}
When user requests '${get.sample.call}'
Then response should have status 'OK'
END
Where, get.sample.call will be in properties file holding request details.

Resources