public abstract class AbstractReporter
extends java.lang.Object
implements io.cucumber.plugin.ConcurrentEventListener
| Modifier and Type | Field and Description |
|---|---|
static com.epam.reportportal.service.tree.TestItemTree |
ITEM_TREE |
protected java.util.function.Supplier<com.epam.reportportal.service.Launch> |
launch |
| Constructor and Description |
|---|
AbstractReporter() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addToTree(RunningContext.ScenarioContext scenarioContext,
java.lang.String text,
io.reactivex.Maybe<java.lang.String> stepId) |
protected void |
afterHooks(io.cucumber.plugin.event.HookType hookType)
Called when before/after-hooks are finished
|
protected void |
afterLaunch()
Finish RP launch
|
protected void |
afterScenario(io.cucumber.plugin.event.TestCaseFinished event)
Finish Cucumber scenario
Put scenario end time in a map to check last scenario end time per feature
|
protected void |
afterStep(io.cucumber.plugin.event.Result result)
Finish Cucumber step
|
protected void |
beforeHooks(io.cucumber.plugin.event.HookType hookType)
Called when before/after-hooks are started
|
protected void |
beforeLaunch()
Manipulations before the launch starts
|
protected void |
beforeScenario(RunningContext.FeatureContext featureContext,
RunningContext.ScenarioContext scenarioContext)
Start Cucumber scenario
|
protected void |
beforeStep(io.cucumber.plugin.event.TestStep testStep)
Start Cucumber step
|
protected com.epam.ta.reportportal.ws.model.FinishTestItemRQ |
buildFinishTestItemRequest(io.reactivex.Maybe<java.lang.String> itemId,
java.util.Date finishTime,
com.epam.reportportal.listeners.ItemStatus status)
Build finish test item request object
|
protected java.lang.String |
buildMultilineArgument(io.cucumber.plugin.event.TestStep step)
Generate multiline argument (DataTable or DocString) representation
|
protected com.epam.reportportal.service.ReportPortal |
buildReportPortal()
Extension point to customize ReportPortal instance
|
protected com.epam.ta.reportportal.ws.model.StartTestItemRQ |
buildStartFeatureRequest(io.cucumber.core.internal.gherkin.ast.Feature feature,
java.net.URI uri)
Extension point to customize feature creation event/request
|
protected com.epam.ta.reportportal.ws.model.StartTestItemRQ |
buildStartHookRequest(io.cucumber.plugin.event.HookType hookType)
Extension point to customize test creation event/request
|
protected com.epam.ta.reportportal.ws.model.StartTestItemRQ |
buildStartScenarioRequest(io.cucumber.plugin.event.TestCase testCase,
java.lang.String name,
java.net.URI uri,
int line)
Extension point to customize scenario creation event/request
|
protected com.epam.ta.reportportal.ws.model.StartTestItemRQ |
buildStartStepRequest(io.cucumber.plugin.event.TestStep testStep,
java.lang.String stepPrefix,
java.lang.String keyword)
Extension point to customize test creation event/request
|
protected void |
embedding(java.lang.String name,
java.lang.String mimeType,
byte[] data)
Send a log with data attached.
|
protected java.util.Set<com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ> |
extractAttributes(java.util.List<?> tags)
Transform tags from Cucumber to RP format
|
protected void |
finishFeature(io.reactivex.Maybe<java.lang.String> itemId,
java.util.Date dateTime)
Finish a feature with specific date and time
|
protected void |
finishTestItem(io.reactivex.Maybe<java.lang.String> itemId)
Finish a test item with no specific status
|
protected java.util.Date |
finishTestItem(io.reactivex.Maybe<java.lang.String> itemId,
io.cucumber.plugin.event.Status status)
Finish a test item with specified status
|
protected java.lang.String |
formatDataTable(java.util.List<java.util.List<java.lang.String>> table)
Converts a table represented as List of Lists to a formatted table string
|
protected java.util.Set<com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ> |
getAttributes(io.cucumber.plugin.event.TestStep testStep)
Returns static attributes defined by
Attributes annotation in code. |
protected java.lang.String |
getCodeRef(io.cucumber.plugin.event.TestStep testStep)
Returns code reference for mapped code
|
protected java.lang.String |
getCodeRef(java.net.URI uri,
int line)
Returns code reference for feature files by URI and text line number
|
protected RunningContext.ScenarioContext |
getCurrentScenarioContext() |
protected java.lang.String |
getDescription(io.cucumber.core.internal.gherkin.ast.Feature feature,
java.net.URI uri)
Build an item description for a feature
|
protected java.lang.String |
getDescription(io.cucumber.plugin.event.TestCase testCase,
java.net.URI uri)
Build an item description for a scenario
|
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.EmbedEvent> |
getEmbedEventHandler() |
protected abstract java.lang.String |
getFeatureTestItemType()
Return RP launch test item name mapped to Cucumber feature
|
protected org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.String> |
getHookTypeAndName(io.cucumber.plugin.event.HookType hookType)
Returns hook type and name as a
Pair |
protected java.util.List<com.epam.ta.reportportal.ws.model.ParameterResource> |
getParameters(java.lang.String codeRef,
io.cucumber.plugin.event.TestStep testStep)
Returns a list of parameters for a step
|
static com.epam.reportportal.service.ReportPortal |
getReportPortal() |
protected abstract java.util.Optional<io.reactivex.Maybe<java.lang.String>> |
getRootItemId() |
protected abstract java.lang.String |
getScenarioTestItemType()
Return RP launch test item name mapped to Cucumber scenario
|
protected java.lang.String |
getStepName(io.cucumber.plugin.event.TestStep testStep)
Generate a step name based on its type (Before Hook / Regular / etc.)
|
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestCaseFinished> |
getTestCaseFinishedHandler() |
protected com.epam.reportportal.service.item.TestCaseIdEntry |
getTestCaseId(java.lang.String codeRef,
java.util.List<io.cucumber.plugin.event.Argument> arguments)
Return a Test Case ID for a feature file
|
protected com.epam.reportportal.service.item.TestCaseIdEntry |
getTestCaseId(io.cucumber.plugin.event.TestStep testStep,
java.lang.String codeRef)
Return a Test Case ID for mapped code
|
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestCaseStarted> |
getTestCaseStartedHandler() |
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestRunFinished> |
getTestRunFinishedHandler() |
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestRunStarted> |
getTestRunStartedHandler() |
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestSourceRead> |
getTestSourceReadHandler() |
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestStepFinished> |
getTestStepFinishedHandler() |
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestStepStarted> |
getTestStepStartedHandler() |
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.WriteEvent> |
getWriteEventHandler() |
protected void |
handleEndOfFeature() |
protected void |
handleStartOfTestCase(io.cucumber.plugin.event.TestCaseStarted event) |
protected void |
handleTestStepFinished(io.cucumber.plugin.event.TestStepFinished event) |
protected void |
handleTestStepStarted(io.cucumber.plugin.event.TestStepStarted event) |
protected void |
hookFinished(io.cucumber.plugin.event.HookTestStep step,
io.cucumber.plugin.event.Result result,
java.lang.Boolean isBefore)
Called when a specific before/after-hook is finished
|
protected com.epam.reportportal.listeners.ItemStatus |
mapItemStatus(io.cucumber.plugin.event.Status status)
Map Cucumber statuses to RP item statuses
|
protected java.lang.String |
mapLevel(io.cucumber.plugin.event.Status cukesStatus)
Map Cucumber statuses to RP log levels
|
protected void |
removeFromTree(RunningContext.ScenarioContext scenarioContext,
java.lang.String text) |
protected void |
reportResult(io.cucumber.plugin.event.Result result,
java.lang.String message)
Report test item result and error (if present)
|
protected void |
sendLog(java.lang.String message)
Send a text log entry to Report Portal with 'INFO' level, using current datetime as timestamp
|
protected void |
sendLog(java.lang.String message,
java.lang.String level)
Send a text log entry to Report Portal using current datetime as timestamp
|
void |
setEventPublisher(io.cucumber.plugin.event.EventPublisher publisher)
Registers an event handler for a specific event.
|
protected static void |
setReportPortal(com.epam.reportportal.service.ReportPortal reportPortal) |
protected io.reactivex.Maybe<java.lang.String> |
startFeature(com.epam.ta.reportportal.ws.model.StartTestItemRQ startFeatureRq)
Start Cucumber Feature
|
protected io.reactivex.Maybe<java.lang.String> |
startHook(io.reactivex.Maybe<java.lang.String> parentId,
com.epam.ta.reportportal.ws.model.StartTestItemRQ rq)
Start before/after-hook item on Report Portal
|
protected void |
startLaunch()
Start RP launch
|
protected io.reactivex.Maybe<java.lang.String> |
startScenario(io.reactivex.Maybe<java.lang.String> featureId,
com.epam.ta.reportportal.ws.model.StartTestItemRQ startScenarioRq)
Start Cucumber Scenario
|
protected io.reactivex.Maybe<java.lang.String> |
startStep(io.reactivex.Maybe<java.lang.String> scenarioId,
com.epam.ta.reportportal.ws.model.StartTestItemRQ startStepRq)
Start Step item on Report Portal
|
public static final com.epam.reportportal.service.tree.TestItemTree ITEM_TREE
protected java.util.function.Supplier<com.epam.reportportal.service.Launch> launch
public static com.epam.reportportal.service.ReportPortal getReportPortal()
protected static void setReportPortal(com.epam.reportportal.service.ReportPortal reportPortal)
public void setEventPublisher(io.cucumber.plugin.event.EventPublisher publisher)
The available events types are:
TestRunStarted - the first event sent.
TestSourceRead - sent for each feature file read, contains the feature file source.
TestCaseStarted - sent before starting the execution of a Test Case(/Pickle/Scenario), contains the Test Case
TestStepStarted - sent before starting the execution of a Test Step, contains the Test Step
TestStepFinished - sent after the execution of a Test Step, contains the Test Step and its Result.
TestCaseFinished - sent after the execution of a Test Case(/Pickle/Scenario), contains the Test Case and its Result.
TestRunFinished - the last event sent.
EmbedEvent - calling scenario.embed in a hook triggers this event.
WriteEvent - calling scenario.write in a hook triggers this event.
setEventPublisher in interface io.cucumber.plugin.ConcurrentEventListenerprotected RunningContext.ScenarioContext getCurrentScenarioContext()
protected void beforeLaunch()
protected com.epam.reportportal.service.ReportPortal buildReportPortal()
protected void afterLaunch()
protected com.epam.ta.reportportal.ws.model.StartTestItemRQ buildStartScenarioRequest(io.cucumber.plugin.event.TestCase testCase,
java.lang.String name,
java.net.URI uri,
int line)
testCase - Cucumber's TestCase objectname - the scenario nameuri - the scenario feature file relative pathline - the scenario text line number@Nonnull
protected io.reactivex.Maybe<java.lang.String> startScenario(@Nonnull
io.reactivex.Maybe<java.lang.String> featureId,
@Nonnull
com.epam.ta.reportportal.ws.model.StartTestItemRQ startScenarioRq)
featureId - parent feature item idstartScenarioRq - scenario start requestprotected void beforeScenario(RunningContext.FeatureContext featureContext, RunningContext.ScenarioContext scenarioContext)
featureContext - current feature contextscenarioContext - current scenario contextprotected void afterScenario(io.cucumber.plugin.event.TestCaseFinished event)
event - Cucumber's TestCaseFinished objectprotected void startLaunch()
@Nullable
protected java.lang.String getStepName(@Nonnull
io.cucumber.plugin.event.TestStep testStep)
testStep - Cucumber's TestStep objectprotected com.epam.ta.reportportal.ws.model.StartTestItemRQ buildStartStepRequest(io.cucumber.plugin.event.TestStep testStep,
java.lang.String stepPrefix,
java.lang.String keyword)
testStep - a cucumber step objectstepPrefix - a prefix of the step (e.g. 'Background')keyword - a step keyword (e.g. 'Given')@Nonnull
protected io.reactivex.Maybe<java.lang.String> startStep(@Nonnull
io.reactivex.Maybe<java.lang.String> scenarioId,
@Nonnull
com.epam.ta.reportportal.ws.model.StartTestItemRQ startStepRq)
scenarioId - parent scenario item idstartStepRq - step start requestprotected void beforeStep(io.cucumber.plugin.event.TestStep testStep)
testStep - a cucumber step objectprotected void afterStep(io.cucumber.plugin.event.Result result)
result - Step resultprotected com.epam.ta.reportportal.ws.model.StartTestItemRQ buildStartHookRequest(io.cucumber.plugin.event.HookType hookType)
hookType - a cucumber hook type object@Nonnull
protected io.reactivex.Maybe<java.lang.String> startHook(@Nonnull
io.reactivex.Maybe<java.lang.String> parentId,
@Nonnull
com.epam.ta.reportportal.ws.model.StartTestItemRQ rq)
parentId - parent item idrq - hook start requestprotected void beforeHooks(io.cucumber.plugin.event.HookType hookType)
hookType - a hook typeprotected void afterHooks(io.cucumber.plugin.event.HookType hookType)
hookType - a hook typeprotected void hookFinished(io.cucumber.plugin.event.HookTestStep step,
io.cucumber.plugin.event.Result result,
java.lang.Boolean isBefore)
step - TestStep objectresult - Hook resultisBefore - - if true, before-hook, if false - after-hook@Nonnull protected abstract java.lang.String getFeatureTestItemType()
@Nonnull protected abstract java.lang.String getScenarioTestItemType()
protected void reportResult(@Nonnull
io.cucumber.plugin.event.Result result,
@Nullable
java.lang.String message)
result - - Cucumber result objectmessage - - optional message to be logged in additionprotected void embedding(@Nullable
java.lang.String name,
@Nullable
java.lang.String mimeType,
@Nonnull
byte[] data)
name - attachment namemimeType - attachment typedata - data to attachprotected void sendLog(java.lang.String message)
message - a text messageprotected void sendLog(java.lang.String message,
java.lang.String level)
message - a text messagelevel - a log level, see standard Log4j / logback logging levels@Nonnull protected abstract java.util.Optional<io.reactivex.Maybe<java.lang.String>> getRootItemId()
@Nonnull
protected com.epam.ta.reportportal.ws.model.StartTestItemRQ buildStartFeatureRequest(@Nonnull
io.cucumber.core.internal.gherkin.ast.Feature feature,
@Nonnull
java.net.URI uri)
feature - a Cucumber's Feature objecturi - a path to the featureprotected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestRunStarted> getTestRunStartedHandler()
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestSourceRead> getTestSourceReadHandler()
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestCaseStarted> getTestCaseStartedHandler()
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestStepStarted> getTestStepStartedHandler()
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestStepFinished> getTestStepFinishedHandler()
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestCaseFinished> getTestCaseFinishedHandler()
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestRunFinished> getTestRunFinishedHandler()
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.EmbedEvent> getEmbedEventHandler()
protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.WriteEvent> getWriteEventHandler()
protected void handleEndOfFeature()
@Nonnull
protected io.reactivex.Maybe<java.lang.String> startFeature(@Nonnull
com.epam.ta.reportportal.ws.model.StartTestItemRQ startFeatureRq)
startFeatureRq - feature start requestprotected void handleStartOfTestCase(@Nonnull
io.cucumber.plugin.event.TestCaseStarted event)
protected void handleTestStepStarted(@Nonnull
io.cucumber.plugin.event.TestStepStarted event)
protected void handleTestStepFinished(@Nonnull
io.cucumber.plugin.event.TestStepFinished event)
protected void addToTree(@Nonnull
RunningContext.ScenarioContext scenarioContext,
@Nullable
java.lang.String text,
@Nonnull
io.reactivex.Maybe<java.lang.String> stepId)
protected void removeFromTree(@Nonnull
RunningContext.ScenarioContext scenarioContext,
@Nullable
java.lang.String text)
@Nonnull
protected com.epam.ta.reportportal.ws.model.FinishTestItemRQ buildFinishTestItemRequest(@Nonnull
io.reactivex.Maybe<java.lang.String> itemId,
@Nullable
java.util.Date finishTime,
@Nullable
com.epam.reportportal.listeners.ItemStatus status)
itemId - item ID referencefinishTime - a datetime object to use as item end timestatus - item result statusprotected void finishFeature(@Nullable
io.reactivex.Maybe<java.lang.String> itemId,
@Nullable
java.util.Date dateTime)
itemId - an ID of the itemdateTime - a date and time object to use as feature end time@Nullable
protected java.util.Date finishTestItem(@Nullable
io.reactivex.Maybe<java.lang.String> itemId,
@Nullable
io.cucumber.plugin.event.Status status)
itemId - an ID of the itemstatus - the status of the itemprotected void finishTestItem(@Nullable
io.reactivex.Maybe<java.lang.String> itemId)
itemId - an ID of the item@Nullable
protected com.epam.reportportal.listeners.ItemStatus mapItemStatus(@Nullable
io.cucumber.plugin.event.Status status)
status - - Cucumber status@Nonnull
protected java.lang.String mapLevel(@Nullable
io.cucumber.plugin.event.Status cukesStatus)
cukesStatus - - Cucumber status@Nonnull
protected java.lang.String formatDataTable(@Nonnull
java.util.List<java.util.List<java.lang.String>> table)
table - a table object@Nonnull
protected java.lang.String buildMultilineArgument(@Nonnull
io.cucumber.plugin.event.TestStep step)
step - - Cucumber step object@Nonnull
protected java.util.Set<com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ> extractAttributes(@Nonnull
java.util.List<?> tags)
tags - - Cucumber tags@Nullable
protected java.util.Set<com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ> getAttributes(@Nonnull
io.cucumber.plugin.event.TestStep testStep)
Attributes annotation in code.testStep - - Cucumber's TestStep object@Nullable
protected java.lang.String getCodeRef(@Nonnull
io.cucumber.plugin.event.TestStep testStep)
testStep - Cucumber's TestStep object@Nonnull
protected java.lang.String getCodeRef(@Nonnull
java.net.URI uri,
int line)
uri - a feature URIline - a scenario line number@Nonnull
protected java.util.List<com.epam.ta.reportportal.ws.model.ParameterResource> getParameters(@Nullable
java.lang.String codeRef,
@Nonnull
io.cucumber.plugin.event.TestStep testStep)
codeRef - a method code reference to retrieve parameter typestestStep - Cucumber's Step object@Nullable
protected com.epam.reportportal.service.item.TestCaseIdEntry getTestCaseId(@Nonnull
io.cucumber.plugin.event.TestStep testStep,
@Nullable
java.lang.String codeRef)
testStep - Cucumber's TestStep objectcodeRef - a code reference@Nullable
protected com.epam.reportportal.service.item.TestCaseIdEntry getTestCaseId(@Nullable
java.lang.String codeRef,
@Nullable
java.util.List<io.cucumber.plugin.event.Argument> arguments)
codeRef - a code referencearguments - a scenario arguments@Nonnull
protected java.lang.String getDescription(@Nonnull
io.cucumber.core.internal.gherkin.ast.Feature feature,
@Nonnull
java.net.URI uri)
feature - a Cucumber's Feature objecturi - a feature URI@Nonnull
protected java.lang.String getDescription(@Nonnull
io.cucumber.plugin.event.TestCase testCase,
@Nonnull
java.net.URI uri)
testCase - a Cucumber's TestCase objecturi - a feature URI@Nonnull
protected org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.String> getHookTypeAndName(@Nonnull
io.cucumber.plugin.event.HookType hookType)
PairhookType - Cucumber's hoo type