Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gaeljw opened this issue Jan 6, 2022 · 2 comments · Fixed by #2459
Milestone

Comments

@gaeljw
Copy link
Member

gaeljw commented Jan 6, 2022

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
@mpkorstanje
Copy link
Contributor

Looks like we're missing a fall back for String and DocString somewhere.

@mpkorstanje
Copy link
Contributor

Fixed in v7.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants