Cancel test execution in BeforeScenario Hook's method
AnsweredHello,
We added scenario title naming convention (squashTMId-title), add I would like to check scenario title in the code and throw an exception if the name doesn't follow the convention.
Right now when I throw an exception in BeforeScenario method the test continue.
What is the proper way to do this ?
Thanks
-
Could you post the exact code of the hook? Because from what you described it should work. You are using the right solution.
0 -
This is the code of my method :
[BeforeScenario]
public void BeforeScenario(ScenarioContext scenarioContext)
{
try
{var alcuinPageObject = new AlcuinPageObject(_browserDriver, _browserInteractions, _specflowOutputHelper, scenarioContext);
// Check scenario name, it should follow naming convention
CheckScenarioName(scenarioContext); // <= this method throw some exceptions
}
catch (Exception ex)
{
Debug.WriteLine(ex);
_specflowOutputHelper?.WriteLine(ex.ToString());
throw;
}
}0 -
Sorry I findout my mistake, initially I didn't rethrow the exception in my catch ...
0 -
👍
That was my assumption but I wanted to be sure.
0
Please sign in to leave a comment.
Comments
4 comments