Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

allure2 listener to output the steps in console

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());

}
like image 646
user3290656 Avatar asked Aug 10 '17 23:08

user3290656


1 Answers

Allure 2 listeners are managed by SPI mechanism. So there're several steps you need to do to make it works:

  • Implement StepLifecycleListener interface and override required methods.
  • Create META-INF/services folders in your project's resources root.
  • Create a new file by the full name of this interface in the above folder.
  • Add the full path to your implementation class into this file.

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

like image 131
Sergey Korol Avatar answered Nov 08 '22 00:11

Sergey Korol