-
Hello all! If I have a Hook method like this: [AfterFeature]
[AfterScenario]
public static void MyHook()
{
if (calledByAfterFeature)
{
// do AfterFeature stuff
}
else
{
// do AfterScenario stuff
}
} Is there a way to determine in what context a particular hook is being called? This is possible for I know it could be argued this is an anti-pattern, and that I should instead create separate methods, but just curious 🙂 |
Beta Was this translation helpful? Give feedback.
Answered by
obligaron
Dec 21, 2024
Replies: 1 comment 1 reply
-
In your case you could look if a [AfterFeature]
[AfterScenario]
public static void MyHook(ITestRunner testRunner)
{
bool calledByAfterFeature = testRunner.ScenarioContext is null;
if (calledByAfterFeature)
{
// do AfterFeature stuff
}
else
{
// do AfterScenario stuff
}
} But as you said, explicit methods would be likely more readable. 😉 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
DrEsteban
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In your case you could look if a
ScenarioContext
is present:But as you said, explicit methods would be likely more readable. 😉