Cucumber MCQ 2
Cucumber MCQ 2
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
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%
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"
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
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")
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