HOME
Are you familiar with Cucumber and want to test your understanding? This post contains 25 useful Cucumber multiple-choice questions (quiz) to self-test your knowledge of Cucumber.
You can find the questions for the below-mentioned answers in this post –
Cucumber Multiple Choice Questions – MCQ1
Answers
1) 2) BDD (Behaviour driven development)
2) 4) All of the above
3) 3) Gherkin
4) 1) Describe the scenarios, behaviour, and expected result of a feature.
Sample Feature File
@LoginPage
Feature: Login to HRM Application
@ValidCredentials
Scenario: Login with valid credentials
Given User is on HRMLogin page "https://opensource-demo.orangehrmlive.com/"
When User enters username as "Admin" and password as "admin123"
Then User should be able to login successfully and new page open
To know more about the Feature File, please refer to this – Cucumber Tutorial – What is Feature File in Cucumber
5) 2) It is an interface between a feature file and a step definition file, and it is used to execute the step definition file corresponding to a feature file.
Sample Test Runner Class
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(plugin = "pretty", features = "src/test/resources/Features/MyHoliday.feature", tags = "@BookOneWayFlight")
public class CucumberRunnerTest {
}
To know more about the Test Runner, please refer to this – Cucumber – JUnit Test Runner Class.
6) 1) It is a Java method with an expression that links it to one or more Gherkin steps. When Cucumber executes a Gherkin statement in a scenario, it will look for a matching step definition to execute.
To know more about the Step Definition, please refer to this – Step Definition in Cucumber.
7) 4) .feature
8) 1) Background 4) Scenario Outline 5) Feature 6) Given 8) When
9) 1) Feature
10) 1) Given
11) 2) When
12) 1) Then
13) 2) But
14) 1) And
15) 3) Background
Below is an example of a Background in a Feature file.
Feature: Login to HRM Application
Background:
Given User is on HRMLogin page "https://opensource-demo.orangehrmlive.com/"
@ValidCredentials
Scenario: Login with valid credentials
When User enters username as "Admin" and password as "admin123"
Then User should be able to login successfully and new page open
@MissingUsername
Scenario: Login with blank username
When User enters username as " " and password as "admin123"
Then User should be able to see a message "Required" below Username
To know more about the Background, please refer to this – Background in Cucumber.
16) 1) A way to run the same scenario with different inputs
To know more about the Scenario Outline, please refer to this – Data Driven Testing using Scenario Outline in Cucumber.
17) 1) A piece of code that runs before or after a scenario or feature
To know more about the Hooks, please refer to this – Hooks in Cucumber.
18) 1) A label that can be applied to a scenario or feature
To know more about the Tags, please refer to this – Tags in Cucumber.
19) 1) To describe the setup, action, and expected result of a scenario
20) 1) Cucumber Reports
21) 4) All of the above
22) 1) @
23) 3) Both 1 and 2
24) 1) ~
25) 2) If