Differences
  • Placement 360 CourseExplore
  • Software testing day - 38

    Last Updated :
    Discuss
    Comments

    Question 1

    What is the primary purpose of Cucumber Hooks?

    • A

      To execute the entire test suite.

    • B

      To manage repetitive tasks before and after each scenario, feature, or step.

    • C

      To define step definitions for each test case.

    • D

      To generate test reports automatically.

    Question 2

    In which of the following scenarios would a Cucumber @Before hook be used?

    • A

      To clean up resources after the scenario finishes.

    • B

      To initialize WebDriver before the scenario begins.

    • C

      To verify the correctness of the login credentials.

    • D

      To map Gherkin steps to Java code.

    Question 3

    How do you associate a specific hook with a particular scenario in Cucumber?

    • A

      By using the @After annotation.

    • B

      By specifying the scenario name in the @Before annotation.

    • C

      By using tags like @LoginTest in both the feature file and hook method.

    • D

      By referencing the scenario name in the TestRunner class.

    Question 4

    What does the @After annotation in Cucumber Hooks do?

    • A

      It initializes WebDriver before the test begins.

    • B

       It cleans up resources, such as closing the WebDriver after the scenario finishes.

    • C

       It sets up the test data.

    • D

      It defines the Gherkin step definitions.

    Question 5

    Which component in the Cucumber test setup contains the actual Gherkin scenarios?

    • A

       TestRunner.java

    • B

       Hooks.java

    • C

       Feature file

    • D

      StepDefinitions.java

    Question 6

    What is the role of the @CucumberOptions annotation in Cucumber?

    • A

      To specify the WebDriver path.

    • B

      To configure the Cucumber test runner with options like feature file path, glue code, and reporting options.

    • C

      To define step methods for the scenarios.

    • D

       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?

    • A

      It allows WebDriver to be injected into the step definition class.

    • B

      It initializes the hooks before each scenario.

    • C

      It enables scenario reporting.

    • D

      It maps Gherkin steps to executable code.

    Question 8

    What is the purpose of creating a TestRunner class in Cucumber?

    • A

      To define the behavior of the test in Gherkin.

    • B

      To run the Cucumber feature files with TestNG.

    • C

      To manage WebDriver initialization.

    • D

      To create hooks for before and after each scenario.

    Question 9

    What would happen if you fail to close WebDriver in the @After hook?

    • A

      The tests would run successfully but would not be recorded in the report.

    • B

      The tests would fail due to an open browser.

    • C

      It might lead to memory leaks, and the browser would remain open.

    • D

      The tests would be skipped.

    Question 10

    How are test reports generated in Cucumber?

    • A

      Through the @Before annotation.

    • B

      Using the plugin option in the @CucumberOptions annotation to specify output formats like HTML or JSON.

    • C

      By manually writing the results after the scenario finishes.

    • D

      By using custom Java classes for reporting.

    There are 10 questions to complete.

    Take a part in the ongoing discussion