Question 1
What is the primary purpose of Cucumber Hooks?
To execute the entire test suite.
To manage repetitive tasks before and after each scenario, feature, or step.
To define step definitions for each test case.
To generate test reports automatically.
Question 2
In which of the following scenarios would a Cucumber @Before hook be used?
To clean up resources after the scenario finishes.
To initialize WebDriver before the scenario begins.
To verify the correctness of the login credentials.
To map Gherkin steps to Java code.
Question 3
How do you associate a specific hook with a particular scenario in Cucumber?
By using the @After annotation.
By specifying the scenario name in the @Before annotation.
By using tags like @LoginTest in both the feature file and hook method.
By referencing the scenario name in the TestRunner class.
Question 4
What does the @After annotation in Cucumber Hooks do?
It initializes WebDriver before the test begins.
It cleans up resources, such as closing the WebDriver after the scenario finishes.
It sets up the test data.
It defines the Gherkin step definitions.
Question 5
Which component in the Cucumber test setup contains the actual Gherkin scenarios?
TestRunner.java
Hooks.java
Feature file
StepDefinitions.java
Question 6
What is the role of the @CucumberOptions annotation in Cucumber?
To specify the WebDriver path.
To configure the Cucumber test runner with options like feature file path, glue code, and reporting options.
To define step methods for the scenarios.
To manage the execution of individual steps in a scenario.
Question 7
In the context of the Hooks class, what is the significance of constructor injection?
It allows WebDriver to be injected into the step definition class.
It initializes the hooks before each scenario.
It enables scenario reporting.
It maps Gherkin steps to executable code.
Question 8
What is the purpose of creating a TestRunner class in Cucumber?
To define the behavior of the test in Gherkin.
To run the Cucumber feature files with TestNG.
To manage WebDriver initialization.
To create hooks for before and after each scenario.
Question 9
What would happen if you fail to close WebDriver in the @After hook?
The tests would run successfully but would not be recorded in the report.
The tests would fail due to an open browser.
It might lead to memory leaks, and the browser would remain open.
The tests would be skipped.
Question 10
How are test reports generated in Cucumber?
Through the @Before annotation.
Using the plugin option in the @CucumberOptions annotation to specify output formats like HTML or JSON.
By manually writing the results after the scenario finishes.
By using custom Java classes for reporting.
There are 10 questions to complete.