1.

What Are Hooks In Cucumber?

Answer»

Hooks are Cucumber's way of allowing for setup to be performed prior to tests being run and teardown to be run afterward. They are defined as executable Ruby blocks, similar to JUnit methods marked with @Before, @After annotations. Conventionally they are placed under support/, and are applied GLOBALLY. Three basic types of hooks exist.

Before - Runs before a SCENARIO

After - Runs after a scenario

Around - Assumes CONTROL and runs around a scenario

ADDITIONAL hooks include

  • BeforeStep
  • AfterStep
  • AfterConfiguration - Runs after Cucumber configuration and is PASSED an instance of the configuration

Hooks are Cucumber's way of allowing for setup to be performed prior to tests being run and teardown to be run afterward. They are defined as executable Ruby blocks, similar to JUnit methods marked with @Before, @After annotations. Conventionally they are placed under support/, and are applied globally. Three basic types of hooks exist.

Before - Runs before a scenario

After - Runs after a scenario

Around - Assumes control and runs around a scenario

Additional hooks include



Discussion

No Comment Found