I am using Allure2 with TestNG. I want to write my own listener which prints @Steps in the console output.
I saw the interface "StepLifecycleListener" in allure but I am not able to implement this listener in TestNg. Any pointers ?
@Override
public void beforeStepStart(final StepResult result) {
System.out.format("Starting step: %s", result.getName());
}
@Override
public void afterStepStop(final StepResult result) {
System.out.format("Completed step: %s", result.getName());
}
Allure 2 listeners are managed by SPI mechanism. So there're several steps you need to do to make it works:
StepLifecycleListener
interface and override required methods.META-INF/services
folders in your project's resources
root.You can find an example in the the following project: https://github.com/sskorol/allure2-testng-report/blob/master/src/test/resources/META-INF/services/io.qameta.allure.listener.StepLifecycleListener
More info about SPI: http://docs.oracle.com/javase/tutorial/sound/SPI-intro.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With