0% found this document useful (0 votes)
15 views3 pages

Cucumber MCQ 2

The document contains a series of multiple-choice questions related to Cucumber, covering topics such as tagging scenarios, defining hooks, passing parameters, and handling data types. Each question is followed by the correct answer, providing a comprehensive overview of Cucumber functionalities and best practices. This serves as a quiz or study guide for individuals looking to enhance their knowledge of Cucumber testing framework.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Cucumber MCQ 2

The document contains a series of multiple-choice questions related to Cucumber, covering topics such as tagging scenarios, defining hooks, passing parameters, and handling data types. Each question is followed by the correct answer, providing a comprehensive overview of Cucumber functionalities and best practices. This serves as a quiz or study guide for individuals looking to enhance their knowledge of Cucumber testing framework.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

How do you specify multiple tags in Cucumber to execute scenarios that match at
least one of them?
a) @Tag1 & @Tag2
b) @Tag1, @Tag2
c) @Tag1 or @Tag2
d) @Tag1 and @Tag2

2. Which Cucumber command runs only scenarios tagged with @smoke?


a) cucumber --tags @smoke
b) mvn test -Dcucumber.filter.tags="@smoke"
c) mvn test -Dtags="@smoke"
d) cucumber --filter @smoke

3. How do you exclude scenarios tagged with @ignore when running Cucumber tests?
a) --tags ~@ignore
b) --exclude @ignore
c) --tags @ignore --skip
d) --remove @ignore

4. What is the correct syntax to define a @Before hook in Cucumber with Java?
a) @Before public void setup() {}
b) Before() {}
c) @Before() setup() {}
d) @Before public setup() {}

5. If both @Before and @After hooks are defined, which one runs first?
a) @Before
b) @After
c) They run in parallel
d) It depends on the scenario

6. How do you define an order for @Before hooks to run in a specific sequence?
a) @Before(order = 1)
b) @Before(priority = 1)
c) @Before(sequence = 1)
d) @Before(step = 1)

7. How can you pass parameters to a Cucumber scenario step using Examples in a
Scenario Outline?
a) <parameter>
b) {parameter}
c) $parameter
d) %parameter%

8. How do you define a step definition to capture a dynamic parameter from a


feature file step?
a) @Given("User logs in with (.+)")
b) @Given("User logs in with {string}")
c) @Given("User logs in with %s")
d) @Given("User logs in with ${string}")

9. What is the default data type of captured parameters in Cucumber expressions?


a) int
b) String
c) Object
d) List<String>

10. What annotation is used to pass data using an Examples table in Cucumber?
a) @Examples
b) @DataTable
c) Scenario Outline
d) @ParameterTable

11. What is the correct way to run scenarios tagged with both @smoke and
@regression together?
a) mvn test -Dcucumber.filter.tags="@smoke,@regression"
b) mvn test -Dcucumber.filter.tags="@smoke and @regression"
c) mvn test -Dcucumber.filter.tags="@smoke & @regression"
d) mvn test -Dcucumber.filter.tags="@smoke or @regression"

12. Which special tag is used to skip a scenario in Cucumber?


a) @Pending
b) @Ignore
c) @Disabled
d) ~@ignore

13. How do you tag all scenarios in a feature file at once?


a) Add the tag above each scenario
b) Add the tag above the Feature: keyword
c) Add the tag below the Scenario: keyword
d) Use @AllScenarios

14. What happens if you define multiple @Before hooks without specifying the order?
a) They run in the order they are defined
b) They run in random order
c) Only the first @Before will execute
d) Only the last @Before will execute

15. How can you share test data between different hooks and step definitions?
a) Using static variables
b) Using Scenario Context or Dependency Injection
c) Using Properties file
d) You can't share data between hooks

16. What is the purpose of the Scenario object in Cucumber hooks?


a) It stores test data
b) It provides runtime information about the scenario
c) It defines the scenario flow
d) It executes test cases

17. Which method is used to pass a list of values to a step using DataTable?
a) List<String>
b) Map<String, String>
c) List<List<String>>
d) DataTable.asList()

18. How do you define a step that accepts an integer parameter using Cucumber
Expressions?
a) @Given("User enters {int} items")
b) @Given("User enters (\\d+) items")
c) @Given("User enters $int items")
d) @Given("User enters {digit} items")

19. Which annotation is used to transform data in Cucumber?


a) @Transformer
b) @ConvertData
c) @ParameterType
d) @DataTransformer

20. What will happen if the parameter type doesn't match the method argument?
a) Test will pass
b) Test will be skipped
c) Cucumber will throw CucumberException
d) Test will automatically convert the data

1. b) @Tag1, @Tag2
2. b) mvn test -Dcucumber.filter.tags="@smoke"
3. a) --tags ~@ignore
4. a) @Before public void setup() {}
5. a) @Before
6. a) @Before(order = 1)
7. a) <parameter>
8. b) @Given("User logs in with {string}")
9. b) String
10. c) Scenario Outline
11 b) @smoke and @regression
12 d) ~@ignore
13 b) Add the tag above the Feature: keyword
14 a) They run in the order they are defined
15 b) Using Scenario Context or Dependency Injection
16 b) It provides runtime information about the scenario
17 d) DataTable.asList()
18 a) @Given("User enters {int} items")
19 c) @ParameterType
20 c) Cucumber will throw CucumberException

You might also like