'After updating cucumber-groovy I get "Access to 'PickleStepTestStep' exceeds its access rights"

After updating cucumber-groovy from version 4.7.1 to 6.1.2 I started getting an error Access to 'PickleStepTestStep' exceeds its access rights. In old version it was in cucumber.api.PickleStepTestStep and now in io.cucumber.core.runner.PickleStepTestStep

As I see PickleStepTestStep now is a private class.

How can I get the current step name now?

Example of how I use it:

class ErrorLogger {

    List<String> errorHolder = new ArrayList<>()

    PickleStepTestStep currentStepDef

    int currentStepDefIndex = 0

    void setNewStepState(TestCase testCase) {
        List<PickleStepTestStep> stepDefs = testCase.getTestSteps().findAll { it instanceof PickleStepTestStep } as List<PickleStepTestStep>

        currentStepDef = stepDefs.get(currentStepDefIndex)
        newStep = true
        currentStepDefIndex++
    }

    private void addNewStepInfoToList() {
        errorHolder.add('############################################################')
        errorHolder.add('[ERROR] STEP NAME: ' + currentStepDef.getStepText())
        newStep = false
    }
}

The same problem I have with TestCase class.

The imports are as follows:

    cucumber_groovy          : "io.cucumber:cucumber-groovy:6.1.2",
    cucumber_junit           : "io.cucumber:cucumber-junit:4.7.1",
    groovy                   : 'org.codehaus.groovy:groovy-all:3.0.5',


Solution 1:[1]

We should only change used class from cucumber.api.PickleStepTestStep to interface from cucumber-plugin: io.cucumber.plugin.event.PickleStepTestStep

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cheparsky