public abstract class LifecycleListener extends Object
LifecycleListener and
override the appropriate methods. If a listener throws an exception while processing a Allure
event, it will be removed for the remainder of the test run.
An example, if you want to log each step, you could write:
public class EachStepLogger extends LifecycleListener {
private Deque names = new LinkedList<>();
@Override
public void fire(StepStartedEvent event) {
names.push(event.getName());
System.out.println(getOffset() + "step started " + names.getFirst());
}
@Override
public void fire(StepFinishedEvent event) {
System.out.println(getOffset() + "step finished " + names.poll());
}
private String getOffset() {
return new String(new char[names.size() == 0 ? 0 : names.size() - 1]).replaceAll("\0", " ");
}
}
To add your listener you should use Java SPI https://docs.oracle.com/javase/tutorial/ext/basics/spi.html
or Allure.addListener(LifecycleListener) method
All listener methods will be invoked after event processing. Do not change given events, it can affect others
listeners.| Constructor and Description |
|---|
LifecycleListener() |
| Modifier and Type | Method and Description |
|---|---|
void |
fire(ClearStepStorageEvent event)
Called when Allure clear current step context.
|
void |
fire(ClearTestStorageEvent event)
Called when Allure clear current test case context.
|
void |
fire(StepEvent event)
Called when Allure process any custom step event, such as
MakeAttachmentEvent |
void |
fire(StepFinishedEvent event)
Called when a step finished
|
void |
fire(StepStartedEvent event)
Called when a step started
|
void |
fire(TestCaseEvent event)
Called when Allure process any custom test case event, such as
AddParameterEvent |
void |
fire(TestCaseFinishedEvent event)
Called when a test case finished
|
void |
fire(TestCaseStartedEvent event)
Called when a test case started
|
void |
fire(TestSuiteEvent event)
Called when Allure process any custom test suite event
|
void |
fire(TestSuiteFinishedEvent event)
Called when a test suite finished
|
public void fire(StepStartedEvent event)
public void fire(StepEvent event)
MakeAttachmentEventpublic void fire(StepFinishedEvent event)
public void fire(TestCaseStartedEvent event)
public void fire(TestCaseEvent event)
AddParameterEventpublic void fire(TestCaseFinishedEvent event)
public void fire(TestSuiteEvent event)
public void fire(TestSuiteFinishedEvent event)
public void fire(ClearStepStorageEvent event)
public void fire(ClearTestStorageEvent event)
Copyright © 2017 Yandex. All rights reserved.