RedMurloc
RedMurloc

Reputation: 137

Cucumber on groovy can't cast null to string when looks for step definition

I have some cucumber tests with step definitions written on groovy, and there is the following error when I run it:

groovy.lang.MissingMethodException: No signature of method: test.steps.StepDefs$_run_closure14.doCall() is applicable for argument types: (null, null, String, Integer, String) values: [null, null, qwer, 21, 1]
Possible solutions: doCall(java.lang.String, java.lang.String, java.lang.String, short, java.lang.String), findAll(), findAll()

Scenario:

Scenario: justscenario
    Then ABC string qwer, short 21 version 1

Step definition:

Then(~'^ABC(?: ([^\\s]*))?(?: for "(\\S+)")? string ([^\\s]*), short (\\d+) version ([^\\s]*)$')
    { String key, String user, String stringId, short shortId, String version -> ...

In this case I don't need first two values so I omit it.
Why first two nulls weren't cast to String? null can be casted to any reference, isn't it?

Cucumber version is 4.8.0
Cucumber-groovy is 4.7.1
Junit is 4.12

Upvotes: 0

Views: 228

Answers (1)

cfrick
cfrick

Reputation: 37033

The error is due to the use of short in the function to be called.

... test.steps.StepDefs$_run_closure14.doCall() is applicable for argument types: (null, null, String, Integer, String) values: [null, null, qwer, 21, 1]

Possible solutions: doCall(java.lang.String, java.lang.String, java.lang.String, short, java.lang.String), findAll(), findAll()

Upvotes: 1

Related Questions