Class ScenarioReporter

  • All Implemented Interfaces:
    io.cucumber.plugin.ConcurrentEventListener, io.cucumber.plugin.Plugin

    public class ScenarioReporter
    extends java.lang.Object
    implements io.cucumber.plugin.ConcurrentEventListener
    Abstract Cucumber 6.x - 7.x formatter for ReportPortal
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected void afterFeature​(io.cucumber.plugin.event.TestCase testCase)
      Verifies whether all scenarios for the feature are finished and finishes the feature when appropriate.
      protected void afterHooks​(io.cucumber.plugin.event.TestCase testCase, io.cucumber.plugin.event.HookTestStep step, io.cucumber.plugin.event.Result result)
      Called when before/after-hooks are finished
      protected void afterHooksSuite​(io.cucumber.plugin.event.TestCase testCase)  
      protected void afterLaunch()
      Finish RP launch
      protected void afterScenario​(io.cucumber.plugin.event.TestCaseFinished event)
      protected void afterScenario​(io.cucumber.plugin.event.TestCase testCase, io.cucumber.plugin.event.Status status, java.lang.Throwable error)
      Finish Cucumber scenario.
      protected void afterStep​(io.cucumber.plugin.event.TestCase testCase, io.cucumber.plugin.event.PickleStepTestStep testStep, io.cucumber.plugin.event.Result result)
      Finish Cucumber step
      protected void beforeHooks​(io.cucumber.plugin.event.TestCase testCase, io.cucumber.plugin.event.HookTestStep testStep)
      Called when before/after-hooks are started
      protected void beforeHooksSuite​(io.cucumber.plugin.event.TestCase testCase, io.cucumber.plugin.event.HookTestStep testStep)  
      protected void beforeLaunch()
      Manipulations before the launch starts
      protected void beforeScenario​(io.cucumber.core.gherkin.Feature feature, io.cucumber.plugin.event.TestCase scenario)
      Deprecated.
      protected void beforeScenario​(io.cucumber.plugin.event.TestCase scenario)
      Start Cucumber scenario
      protected void beforeStep​(io.cucumber.plugin.event.TestCase testCase, io.cucumber.plugin.event.PickleStepTestStep step)
      Start Cucumber step
      protected com.epam.ta.reportportal.ws.model.FinishTestItemRQ buildFinishTestItemRequest​(io.reactivex.Maybe<java.lang.String> itemId, java.time.Instant 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.gherkin.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.TestCase testCase, io.cucumber.plugin.event.HookTestStep testStep)
      Extension point to customize test creation event/request
      protected com.epam.ta.reportportal.ws.model.StartTestItemRQ buildStartHookSuiteRequest​(io.cucumber.plugin.event.HookTestStep testStep)  
      protected com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ buildStartLaunchRq​(java.time.Instant startTime, com.epam.reportportal.listeners.ListenerParameters parameters)
      A method for creation a Start Launch request which will be sent to ReportPortal.
      protected com.epam.ta.reportportal.ws.model.StartTestItemRQ buildStartRuleRequest​(io.cucumber.plugin.event.Node.Rule rule)
      Extension point to customize scenario creation event/request
      protected com.epam.ta.reportportal.ws.model.StartTestItemRQ buildStartScenarioRequest​(io.cucumber.plugin.event.TestCase testCase)
      Extension point to customize scenario creation event/request
      protected com.epam.ta.reportportal.ws.model.StartTestItemRQ buildStartStepRequest​(io.cucumber.plugin.event.PickleStepTestStep 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.Collection<?> tags)
      Transform tags from Cucumber to RP format
      protected void finishFeature​(FeatureContext f)  
      protected void finishTestItem​(io.reactivex.Maybe<java.lang.String> itemId)
      Finish a test item with no specific status
      protected void finishTestItem​(io.reactivex.Maybe<java.lang.String> itemId, com.epam.reportportal.listeners.ItemStatus status)
      Finish a test item with specified status
      protected java.time.Instant finishTestItem​(io.reactivex.Maybe<java.lang.String> itemId, com.epam.reportportal.listeners.ItemStatus status, java.time.Instant dateTime)
      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.TestCase testCase)  
      protected java.lang.String getCodeRef​(io.cucumber.core.gherkin.Feature feature)
      Returns code reference for feature files by URI and text line number
      protected java.lang.String getCodeRef​(io.cucumber.plugin.event.TestCase testCase, java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,​java.lang.String>> parameters)
      Returns code reference for feature files by URI and text line number
      static ScenarioReporter getCurrent()
      Returns a reporter instance for the current thread.
      protected java.lang.String getDescription​(io.cucumber.core.gherkin.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 java.lang.String getHookName​(io.cucumber.plugin.event.HookType hookType)
      Returns hook type and name as a Pair
      com.epam.reportportal.service.tree.TestItemTree getItemTree()  
      com.epam.reportportal.service.Launch getLaunch()  
      protected java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,​java.lang.String>> getParameters​(io.cucumber.plugin.event.TestCase testCase)
      Extract parameters from Examples table for the current Scenario Outline
      protected java.util.List<com.epam.ta.reportportal.ws.model.ParameterResource> getParameters​(io.cucumber.plugin.event.TestStep testStep)
      Returns a list of parameters for a step
      com.epam.reportportal.service.ReportPortal getReportPortal()  
      protected java.lang.String getStepName​(io.cucumber.plugin.event.PickleStepTestStep testStep)
      Generate a step name.
      protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestCaseFinished> getTestCaseFinishedHandler()  
      protected java.lang.String getTestCaseId​(io.cucumber.plugin.event.TestCase testCase, java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,​java.lang.String>> parameters)
      Return a Test Case ID for a scenario in a feature file
      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.TestSourceParsed> getTestSourceParsedHandler()  
      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 handleEmbedEvent​(io.cucumber.plugin.event.EmbedEvent event)
      Handles a Cucumber EmbedEvent by forwarding the attachment to ReportPortal.
      protected void handleFinishOfLaunch​(io.cucumber.plugin.event.TestRunFinished event)
      Handles the Cucumber TestRunFinished event by finalizing the ReportPortal launch.
      protected void handleFinishOfTestCase​(io.cucumber.plugin.event.TestCaseFinished event)
      Handles a Cucumber TestCaseFinished event by finishing the Scenario and, if applicable, completing the Feature when all scenarios are done.
      protected void handleSourceEvents​(io.cucumber.plugin.event.TestSourceParsed parseEvent)
      Handles a Cucumber TestSourceParsed event by materializing feature metadata into internal context structures.
      protected void handleStartOfLaunch​(io.cucumber.plugin.event.TestRunStarted event)
      Handles the Cucumber TestRunStarted event by initializing the ReportPortal launch.
      protected void handleStartOfTestCase​(io.cucumber.plugin.event.TestCaseStarted event)
      Handles a Cucumber TestCaseStarted event by preparing and starting corresponding Feature/Rule/Scenario items in ReportPortal.
      protected void handleTestStepFinished​(io.cucumber.plugin.event.TestStepFinished event)
      Handles a Cucumber TestStepFinished event.
      protected void handleTestStepStarted​(io.cucumber.plugin.event.TestStepStarted event)
      Handles a Cucumber TestStepStarted event.
      protected void handleWriteEvent​(io.cucumber.plugin.event.WriteEvent event)
      Handles a Cucumber WriteEvent by sending the provided text to ReportPortal.
      protected com.epam.reportportal.listeners.ItemStatus mapItemStatus​(io.cucumber.plugin.event.Status status)
      Map Cucumber statuses to RP item statuses
      protected void reportResult​(io.cucumber.plugin.event.Result result)
      Report test item result and error (if present)
      protected void sendLog​(java.lang.String message)
      Send a text log entry to ReportPortal with 'INFO' level, using current datetime as timestamp
      void setEventPublisher​(io.cucumber.plugin.event.EventPublisher publisher)
      Registers an event handler for a specific event.
      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 ReportPortal
      protected io.reactivex.Maybe<java.lang.String> startRule​(io.reactivex.Maybe<java.lang.String> featureId, com.epam.ta.reportportal.ws.model.StartTestItemRQ ruleRq)
      Start Rule item on ReportPortal
      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 ReportPortal
      protected io.reactivex.Maybe<java.lang.String> startVirtualStep​(io.reactivex.Maybe<java.lang.String> scenarioId, io.reactivex.Maybe<java.lang.String> virtualStepId, com.epam.ta.reportportal.ws.model.StartTestItemRQ startStepRq)
      Start virtual step item on ReportPortal
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • BACKGROUND_PREFIX

        public static final java.lang.String BACKGROUND_PREFIX
        See Also:
        Constant Field Values
      • WORKING_DIRECTORY

        protected static final java.net.URI WORKING_DIRECTORY
      • DOCSTRING_DECORATOR

        protected static final java.lang.String DOCSTRING_DECORATOR
        See Also:
        Constant Field Values
    • Constructor Detail

      • ScenarioReporter

        public ScenarioReporter()
    • Method Detail

      • getCurrent

        @Nonnull
        public static ScenarioReporter getCurrent()
        Returns a reporter instance for the current thread.
        Returns:
        reporter instance for the current thread
      • buildStartLaunchRq

        protected com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ buildStartLaunchRq​(java.time.Instant startTime,
                                                                                            com.epam.reportportal.listeners.ListenerParameters parameters)
        A method for creation a Start Launch request which will be sent to ReportPortal. You can customize it by overriding the method.
        Parameters:
        startTime - launch start time, which will be set into the result request
        parameters - ReportPortal client parameters
        Returns:
        a Start Launch request instance
      • getItemTree

        @Nonnull
        public com.epam.reportportal.service.tree.TestItemTree getItemTree()
        Returns:
        a full Test Item Tree with attributes
      • getReportPortal

        @Nonnull
        public com.epam.reportportal.service.ReportPortal getReportPortal()
        Returns:
        a ReportPortal class instance which is used to communicate with the portal
      • getLaunch

        @Nonnull
        public com.epam.reportportal.service.Launch getLaunch()
        Returns:
        a ReportPortal Launch class instance which is used in test item reporting
      • beforeLaunch

        protected void beforeLaunch()
        Manipulations before the launch starts
      • buildReportPortal

        protected com.epam.reportportal.service.ReportPortal buildReportPortal()
        Extension point to customize ReportPortal instance
        Returns:
        ReportPortal
      • afterLaunch

        protected void afterLaunch()
        Finish RP launch
      • extractAttributes

        @Nonnull
        protected java.util.Set<com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ> extractAttributes​(@Nonnull
                                                                                                                java.util.Collection<?> tags)
        Transform tags from Cucumber to RP format
        Parameters:
        tags - - Cucumber tags
        Returns:
        set of tags
      • getParameters

        @Nullable
        protected java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,​java.lang.String>> getParameters​(@Nonnull
                                                                                                                             io.cucumber.plugin.event.TestCase testCase)
        Extract parameters from Examples table for the current Scenario Outline
        Parameters:
        testCase - Cucumber's TestCase object
        Returns:
        a list of parameter pairs or null if failed to extract
      • getCodeRef

        @Nonnull
        protected java.lang.String getCodeRef​(@Nonnull
                                              io.cucumber.plugin.event.TestCase testCase,
                                              @Nullable
                                              java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,​java.lang.String>> parameters)
        Returns code reference for feature files by URI and text line number
        Parameters:
        testCase - Cucumber's TestCase object
        parameters - a scenario parameters
        Returns:
        a code reference
      • getAttributes

        protected java.util.Set<com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ> getAttributes​(io.cucumber.plugin.event.TestCase testCase)
      • getTestCaseId

        @Nonnull
        protected java.lang.String getTestCaseId​(@Nonnull
                                                 io.cucumber.plugin.event.TestCase testCase,
                                                 @Nullable
                                                 java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,​java.lang.String>> parameters)
        Return a Test Case ID for a scenario in a feature file
        Parameters:
        testCase - Cucumber's TestCase object
        parameters - a scenario parameters
        Returns:
        Test Case ID
      • buildStartScenarioRequest

        @Nonnull
        protected com.epam.ta.reportportal.ws.model.StartTestItemRQ buildStartScenarioRequest​(@Nonnull
                                                                                              io.cucumber.plugin.event.TestCase testCase)
        Extension point to customize scenario creation event/request
        Parameters:
        testCase - Cucumber's TestCase object
        Returns:
        start test item request ready to send on RP
      • startScenario

        @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)
        Start Cucumber Scenario
        Parameters:
        featureId - parent feature item id
        startScenarioRq - scenario start request
        Returns:
        scenario item id
      • finishTestItem

        protected java.time.Instant finishTestItem​(@Nullable
                                                   io.reactivex.Maybe<java.lang.String> itemId,
                                                   @Nullable
                                                   com.epam.reportportal.listeners.ItemStatus status,
                                                   @Nullable
                                                   java.time.Instant dateTime)
        Finish a test item with specified status
        Parameters:
        itemId - an ID of the item
        status - the status of the item
        dateTime - a date and time object to use as feature end time
        Returns:
        a date and time object of the finish event
      • finishTestItem

        protected void finishTestItem​(@Nullable
                                      io.reactivex.Maybe<java.lang.String> itemId,
                                      @Nullable
                                      com.epam.reportportal.listeners.ItemStatus status)
        Finish a test item with specified status
        Parameters:
        itemId - an ID of the item
        status - the status of the item
      • finishTestItem

        protected void finishTestItem​(@Nullable
                                      io.reactivex.Maybe<java.lang.String> itemId)
        Finish a test item with no specific status
        Parameters:
        itemId - an ID of the item
      • startHook

        @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)
        Start before/after-hook item on ReportPortal
        Parameters:
        parentId - parent item id
        rq - hook start request
        Returns:
        hook item id
      • beforeHooksSuite

        protected void beforeHooksSuite​(@Nonnull
                                        io.cucumber.plugin.event.TestCase testCase,
                                        @Nonnull
                                        io.cucumber.plugin.event.HookTestStep testStep)
      • afterHooksSuite

        protected void afterHooksSuite​(@Nonnull
                                       io.cucumber.plugin.event.TestCase testCase)
      • afterScenario

        protected void afterScenario​(@Nonnull
                                     io.cucumber.plugin.event.TestCase testCase,
                                     @Nullable
                                     io.cucumber.plugin.event.Status status,
                                     @Nullable
                                     java.lang.Throwable error)
        Finish Cucumber scenario. Put scenario end time in a map to check last scenario end time per feature.
        Parameters:
        testCase - Cucumber's TestCase object
        status - Cucumber's status object
        error - the error being thrown by the Test Case (if any)
      • startFeature

        @Nonnull
        protected io.reactivex.Maybe<java.lang.String> startFeature​(@Nonnull
                                                                    com.epam.ta.reportportal.ws.model.StartTestItemRQ startFeatureRq)
        Start Cucumber Feature
        Parameters:
        startFeatureRq - feature start request
        Returns:
        feature item id
      • afterFeature

        protected void afterFeature​(@Nonnull
                                    io.cucumber.plugin.event.TestCase testCase)
        Verifies whether all scenarios for the feature are finished and finishes the feature when appropriate.
        Parameters:
        testCase - Cucumber's TestCase object
      • afterScenario

        @Deprecated
        protected void afterScenario​(io.cucumber.plugin.event.TestCaseFinished event)
        Parameters:
        event - Cucumber's TestCaseFinished object
      • getStepName

        @Nullable
        protected java.lang.String getStepName​(@Nonnull
                                               io.cucumber.plugin.event.PickleStepTestStep testStep)
        Generate a step name.
        Parameters:
        testStep - Cucumber's TestStep object
        Returns:
        a step name
      • getParameters

        @Nonnull
        protected java.util.List<com.epam.ta.reportportal.ws.model.ParameterResource> getParameters​(@Nonnull
                                                                                                    io.cucumber.plugin.event.TestStep testStep)
        Returns a list of parameters for a step
        Parameters:
        testStep - Cucumber's Step object
        Returns:
        a list of parameters or empty list if none
      • buildStartStepRequest

        @Nonnull
        protected com.epam.ta.reportportal.ws.model.StartTestItemRQ buildStartStepRequest​(@Nonnull
                                                                                          io.cucumber.plugin.event.PickleStepTestStep testStep,
                                                                                          @Nullable
                                                                                          java.lang.String stepPrefix,
                                                                                          @Nullable
                                                                                          java.lang.String keyword)
        Extension point to customize test creation event/request
        Parameters:
        testStep - a cucumber step object
        stepPrefix - a prefix of the step (e.g. 'Background')
        keyword - a step keyword (e.g. 'Given')
        Returns:
        a Request to ReportPortal
      • startVirtualStep

        @Nonnull
        protected io.reactivex.Maybe<java.lang.String> startVirtualStep​(@Nonnull
                                                                        io.reactivex.Maybe<java.lang.String> scenarioId,
                                                                        @Nonnull
                                                                        io.reactivex.Maybe<java.lang.String> virtualStepId,
                                                                        @Nonnull
                                                                        com.epam.ta.reportportal.ws.model.StartTestItemRQ startStepRq)
        Start virtual step item on ReportPortal
        Parameters:
        scenarioId - parent scenario item id
        virtualStepId - virtual step item id
        startStepRq - step start request
        Returns:
        step item id
      • startStep

        @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)
        Start Step item on ReportPortal
        Parameters:
        scenarioId - parent scenario item id
        startStepRq - step start request
        Returns:
        step item id
      • beforeStep

        protected void beforeStep​(@Nonnull
                                  io.cucumber.plugin.event.TestCase testCase,
                                  @Nonnull
                                  io.cucumber.plugin.event.PickleStepTestStep step)
        Start Cucumber step
        Parameters:
        testCase - Cucumber's TestCase object
        step - a cucumber step object
      • afterStep

        protected void afterStep​(@Nonnull
                                 io.cucumber.plugin.event.TestCase testCase,
                                 @Nonnull
                                 io.cucumber.plugin.event.PickleStepTestStep testStep,
                                 @Nonnull
                                 io.cucumber.plugin.event.Result result)
        Finish Cucumber step
        Parameters:
        testCase - Cucumber's TestCase object
        testStep - a cucumber step object
        result - Step result
      • getHookName

        @Nonnull
        protected java.lang.String getHookName​(@Nonnull
                                               io.cucumber.plugin.event.HookType hookType)
        Returns hook type and name as a Pair
        Parameters:
        hookType - Cucumber's hoo type
        Returns:
        a pair of type and name
      • buildStartHookSuiteRequest

        protected com.epam.ta.reportportal.ws.model.StartTestItemRQ buildStartHookSuiteRequest​(@Nonnull
                                                                                               io.cucumber.plugin.event.HookTestStep testStep)
      • buildStartHookRequest

        @Nonnull
        protected com.epam.ta.reportportal.ws.model.StartTestItemRQ buildStartHookRequest​(@Nonnull
                                                                                          io.cucumber.plugin.event.TestCase testCase,
                                                                                          @Nonnull
                                                                                          io.cucumber.plugin.event.HookTestStep testStep)
        Extension point to customize test creation event/request
        Parameters:
        testCase - Cucumber's TestCase object
        testStep - a cucumber step object
        Returns:
        Request to ReportPortal
      • beforeHooks

        protected void beforeHooks​(@Nonnull
                                   io.cucumber.plugin.event.TestCase testCase,
                                   @Nonnull
                                   io.cucumber.plugin.event.HookTestStep testStep)
        Called when before/after-hooks are started
        Parameters:
        testCase - a Cucumber's TestCase object
        testStep - Cucumber's TestStep object
      • afterHooks

        protected void afterHooks​(@Nonnull
                                  io.cucumber.plugin.event.TestCase testCase,
                                  @Nonnull
                                  io.cucumber.plugin.event.HookTestStep step,
                                  io.cucumber.plugin.event.Result result)
        Called when before/after-hooks are finished
        Parameters:
        testCase - a Cucumber's TestCase object
        step - a cucumber step object
        result - a cucumber result object
      • reportResult

        protected void reportResult​(@Nonnull
                                    io.cucumber.plugin.event.Result result)
        Report test item result and error (if present)
        Parameters:
        result - - Cucumber result object
      • embedding

        protected void embedding​(@Nullable
                                 java.lang.String name,
                                 @Nullable
                                 java.lang.String mimeType,
                                 @Nonnull
                                 byte[] data)
        Send a log with data attached.
        Parameters:
        name - attachment name
        mimeType - attachment type
        data - data to attach
      • sendLog

        protected void sendLog​(@Nullable
                               java.lang.String message)
        Send a text log entry to ReportPortal with 'INFO' level, using current datetime as timestamp
        Parameters:
        message - a text message
      • buildStartRuleRequest

        @Nonnull
        protected com.epam.ta.reportportal.ws.model.StartTestItemRQ buildStartRuleRequest​(@Nonnull
                                                                                          io.cucumber.plugin.event.Node.Rule rule)
        Extension point to customize scenario creation event/request
        Parameters:
        rule - the rule node
        Returns:
        start test item request ready to send on RP
      • startRule

        @Nonnull
        protected io.reactivex.Maybe<java.lang.String> startRule​(@Nonnull
                                                                 io.reactivex.Maybe<java.lang.String> featureId,
                                                                 @Nonnull
                                                                 com.epam.ta.reportportal.ws.model.StartTestItemRQ ruleRq)
        Start Rule item on ReportPortal
        Parameters:
        featureId - parent item id
        ruleRq - Rule start request
        Returns:
        hook item id
      • beforeScenario

        protected void beforeScenario​(@Nonnull
                                      io.cucumber.plugin.event.TestCase scenario)
        Start Cucumber scenario
        Parameters:
        scenario - current scenario object
      • beforeScenario

        @Deprecated
        protected void beforeScenario​(@Nonnull
                                      io.cucumber.core.gherkin.Feature feature,
                                      @Nonnull
                                      io.cucumber.plugin.event.TestCase scenario)
        Deprecated.
        Parameters:
        feature - current feature object
        scenario - current scenario object
      • getCodeRef

        @Nonnull
        protected java.lang.String getCodeRef​(@Nonnull
                                              io.cucumber.core.gherkin.Feature feature)
        Returns code reference for feature files by URI and text line number
        Parameters:
        feature - a Cucumber's Feature object
        Returns:
        a code reference
      • buildStartFeatureRequest

        @Nonnull
        protected com.epam.ta.reportportal.ws.model.StartTestItemRQ buildStartFeatureRequest​(@Nonnull
                                                                                             io.cucumber.core.gherkin.Feature feature,
                                                                                             @Nonnull
                                                                                             java.net.URI uri)
        Extension point to customize feature creation event/request
        Parameters:
        feature - a Cucumber's Feature object
        uri - a path to the feature
        Returns:
        Request to ReportPortal
      • handleStartOfLaunch

        protected void handleStartOfLaunch​(io.cucumber.plugin.event.TestRunStarted event)
        Handles the Cucumber TestRunStarted event by initializing the ReportPortal launch.

        Delegates to beforeLaunch() to ensure the launch is created and prepared.

        Parameters:
        event - the test run started event
      • handleFinishOfLaunch

        protected void handleFinishOfLaunch​(io.cucumber.plugin.event.TestRunFinished event)
        Handles the Cucumber TestRunFinished event by finalizing the ReportPortal launch.

        Delegates to afterLaunch() to properly close the launch.

        Parameters:
        event - the test run finished event
      • handleSourceEvents

        protected void handleSourceEvents​(io.cucumber.plugin.event.TestSourceParsed parseEvent)
        Handles a Cucumber TestSourceParsed event by materializing feature metadata into internal context structures. For each node provided by the event:
        • If the node is a Feature, a new FeatureContext is created and stored in featureContextMap under the feature URI.
        • For any other node type, a warning is logged and the node is ignored.

        The populated featureContextMap is later used to resolve feature/rule/scenario contexts during execution.

        Parameters:
        parseEvent - the parsed source event containing Gherkin AST nodes for feature files
      • handleStartOfTestCase

        protected void handleStartOfTestCase​(@Nonnull
                                             io.cucumber.plugin.event.TestCaseStarted event)
        Handles a Cucumber TestCaseStarted event by preparing and starting corresponding Feature/Rule/Scenario items in ReportPortal.

        Ensures the Feature is started (if not already), then initializes Scenario context and starts the Scenario item.

        Parameters:
        event - the test case started event
      • handleFinishOfTestCase

        protected void handleFinishOfTestCase​(io.cucumber.plugin.event.TestCaseFinished event)
        Handles a Cucumber TestCaseFinished event by finishing the Scenario and, if applicable, completing the Feature when all scenarios are done.

        Performs hooks suite finalization, reports the Scenario result, and triggers feature completion checks.

        Parameters:
        event - the test case finished event
      • handleTestStepStarted

        protected void handleTestStepStarted​(@Nonnull
                                             io.cucumber.plugin.event.TestStepStarted event)
        Handles a Cucumber TestStepStarted event.

        Starts a corresponding hook or step item depending on the runtime type of the step. Logs a warning for unknown step types.

        Parameters:
        event - the test step started event
      • handleTestStepFinished

        protected void handleTestStepFinished​(@Nonnull
                                              io.cucumber.plugin.event.TestStepFinished event)
        Handles a Cucumber TestStepFinished event.

        Finalizes the corresponding hook or step item depending on the runtime type of the step. Logs a warning for unknown step types.

        Parameters:
        event - the test step finished event
      • handleEmbedEvent

        protected void handleEmbedEvent​(io.cucumber.plugin.event.EmbedEvent event)
        Handles a Cucumber EmbedEvent by forwarding the attachment to ReportPortal.

        Delegates to embedding(String, String, byte[]) to send the data.

        Parameters:
        event - the embed event containing name, media type and data
      • handleWriteEvent

        protected void handleWriteEvent​(io.cucumber.plugin.event.WriteEvent event)
        Handles a Cucumber WriteEvent by sending the provided text to ReportPortal.

        Delegates to sendLog(String).

        Parameters:
        event - the write event carrying the text to log
      • getTestRunStartedHandler

        protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestRunStarted> getTestRunStartedHandler()
      • getTestSourceParsedHandler

        protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestSourceParsed> getTestSourceParsedHandler()
      • getTestCaseStartedHandler

        protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestCaseStarted> getTestCaseStartedHandler()
      • getTestStepStartedHandler

        protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestStepStarted> getTestStepStartedHandler()
      • getTestStepFinishedHandler

        protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestStepFinished> getTestStepFinishedHandler()
      • getTestCaseFinishedHandler

        protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestCaseFinished> getTestCaseFinishedHandler()
      • getTestRunFinishedHandler

        protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.TestRunFinished> getTestRunFinishedHandler()
      • getEmbedEventHandler

        protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.EmbedEvent> getEmbedEventHandler()
      • getWriteEventHandler

        protected io.cucumber.plugin.event.EventHandler<io.cucumber.plugin.event.WriteEvent> getWriteEventHandler()
      • setEventPublisher

        public void setEventPublisher​(io.cucumber.plugin.event.EventPublisher publisher)
        Registers an event handler for a specific event.

        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.
        Specified by:
        setEventPublisher in interface io.cucumber.plugin.ConcurrentEventListener
      • buildFinishTestItemRequest

        @Nonnull
        protected com.epam.ta.reportportal.ws.model.FinishTestItemRQ buildFinishTestItemRequest​(@Nonnull
                                                                                                io.reactivex.Maybe<java.lang.String> itemId,
                                                                                                @Nullable
                                                                                                java.time.Instant finishTime,
                                                                                                @Nullable
                                                                                                com.epam.reportportal.listeners.ItemStatus status)
        Build finish test item request object
        Parameters:
        itemId - item ID reference
        finishTime - a datetime object to use as item end time
        status - item result status
        Returns:
        finish request
      • mapItemStatus

        @Nullable
        protected com.epam.reportportal.listeners.ItemStatus mapItemStatus​(@Nullable
                                                                           io.cucumber.plugin.event.Status status)
        Map Cucumber statuses to RP item statuses
        Parameters:
        status - - Cucumber status
        Returns:
        RP test item status and null if status is null
      • formatDataTable

        @Nonnull
        protected java.lang.String formatDataTable​(@Nonnull
                                                   java.util.List<java.util.List<java.lang.String>> table)
        Converts a table represented as List of Lists to a formatted table string
        Parameters:
        table - a table object
        Returns:
        string representation of the table
      • buildMultilineArgument

        @Nonnull
        protected java.lang.String buildMultilineArgument​(@Nonnull
                                                          io.cucumber.plugin.event.TestStep step)
        Generate multiline argument (DataTable or DocString) representation
        Parameters:
        step - - Cucumber step object
        Returns:
        - transformed multiline argument (or empty string if there is none)
      • getDescription

        @Nonnull
        protected java.lang.String getDescription​(io.cucumber.core.gherkin.Feature feature,
                                                  @Nonnull
                                                  java.net.URI uri)
        Build an item description for a feature
        Parameters:
        feature - a Cucumber's Feature object
        uri - a feature URI
        Returns:
        item description
      • getDescription

        @Nonnull
        protected java.lang.String getDescription​(@Nonnull
                                                  io.cucumber.plugin.event.TestCase testCase,
                                                  @Nonnull
                                                  java.net.URI uri)
        Build an item description for a scenario
        Parameters:
        testCase - a Cucumber's TestCase object
        uri - a feature URI
        Returns:
        item description