I want to do execute [AfterTestRun]
attribute marked method after test fails of [Binding]
attribute marked class. How can I achieve something like:
[Binding]
public class TestsRunner
{
[AfterTestFails] // There is no such attribute
public static void DoStuff()
{
}
}
or
[Binding]
public class TestsRunner
{
[AfterTestRun]
public static void DoStuff()
{
if(ScenarioContext.Current.TestHasFailed) // There is no such property
{
// Do stuff
}
}
}
After reading some documentation here I have found the next solution:
[Binding]
public class TestsRunner
{
[AfterScenario]
public void TakeScreenShot()
{
if(ScenarioContext.Current.TestError != null)
{
WebBrowser.TakeScreenShot(); // Your custom browser take screenshot method
}
}
}