Skip to content

CucumberDocStringException when using docstring with content type but no DocStringType defined #2458

Closed
@gaeljw

Description

@gaeljw

Describe the bug
Upgrading to version 7.2.0/7.2.1 breaks some of our existing scenarios where a docstring with content type is used but no custom DocStringType is defined.

To Reproduce

Scenario:

Feature: test

  @test
  Scenario: test
    Given I have some json docstring without DocStringType
    """json
    {}
    """

Glue code:

@Given("I have some json docstring without DocStringType")
public void test(String str) {
    assertEquals("{}", str);
}

Error:

io.cucumber.core.exception.CucumberException: Could not convert arguments for step [I have some json docstring without DocStringType] defined at 'features.steps.Steps.test(java.lang.String)'.
	at io.cucumber.core.runner.PickleStepDefinitionMatch.couldNotConvertArguments(PickleStepDefinitionMatch.java:112)
	at io.cucumber.core.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:56)
...
Caused by: io.cucumber.docstring.CucumberDocStringException: It appears you did not register docstring type for 'json' or java.lang.String
	at io.cucumber.docstring.DocStringTypeRegistryDocStringConverter.convert(DocStringTypeRegistryDocStringConverter.java:36)
	at io.cucumber.docstring.DocString.convert(DocString.java:55)
	at io.cucumber.core.stepexpression.StepExpressionFactory.lambda$createExpression$1(StepExpressionFactory.java:72)
	at io.cucumber.core.stepexpression.DocStringArgument.getValue(DocStringArgument.java:19)
	at io.cucumber.core.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:47)
	... 39 more

Expected behavior
I'm not sure if the usage we had until now was supposed to be working but it actually was, thus I would expect no change for a minor version upgrade.

Moreover I'd like to be able to define content type on docstring without having to explicitly define a DocStringType if the step is expecting a String. Shouldn't there be a default converter to String?

Your Environment

  • Versions used: 7.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions