How to get the Status of a Scenario in afterScenario hook in Gauge?

557 Views Asked by At

I have a question Gauge automation framework.

I am trying to get the status of the Scenario i.e., Passed or Failed in the afterScenario hook and store it using DataStore, any idea how to get that?

I use my framework in Python, but any programming language will do.

1

There are 1 best solutions below

0
bugdiver On

@Sam You could check the current scenario status in AfterScenario hook using the ExecutionContext store status of that scenario in SpecDataStore and then access that in the BeforeScenario hook of later scenario. The scenario and hooks could be tagged so specific hook runs only for specific scenarios.

Example:

@AfterScenario("tag_for_scenario1")
def store_status(context):
    datastore.spec["scenario_1_passed"] = context.scenario.is_failing


@BeforeScenario("tag_for_scenario2")
def check_status():
  if not datastore.spec["scenario_1_passed"]:
     raise Exception("prerequisite scenario failed")