question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Undefined step reference - Java8 Lambda - Kotlin

See original GitHub issue

Java - 8 Kotlin - 1.3 Cucumber - 4.1.1 IntelliJ - 2018.2.5 Cucumber for Java Plugin - 182.3934 Windows 10 64

Example Class:

import cucumber.api.java8.En
import org.testng.Assert

class ThenSteps(private val contextHolder: contextHolder) : En {
    private lateinit var Response response;

    init {

        BeforeStep { scenario ->
            contextHolder.getResponse()?.let {
                response = it
            }
        }

        Then("^I receive a response status code of (\\d+)$") { statusCode: Int ->
            Assert.assertEquals(response.statusCode(), statusCode)
        }

    }
}

In my feature file all of my steps are underlined with “Undefined step reference: …”

If I right click and run feature in IntelliJ, but manually point the glue to my steps classes, I then get these errors:

java.lang.NoSuchMethodError: io.cucumber.stepexpression.ArgumentMatcher.argumentsFrom(Lgherkin/pickles/PickleStep;)Ljava/util/List; at cucumber.runtime.java8.Java8StepDefinition.matchedArguments(Java8StepDefinition.java:93) at cucumber.runner.Glue.stepDefinitionMatches(Glue.java:104) at cucumber.runner.Glue.stepDefinitionMatch(Glue.java:82) at cucumber.runner.Runner.addTestStepsForPickleSteps(Runner.java:64) at cucumber.runner.Runner.createTestCaseForPickle(Runner.java:54) at cucumber.runner.Runner.runPickle(Runner.java:39) at cucumber.runtime.Runtime$1.run(Runtime.java:84) at cucumber.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:220) at cucumber.runtime.Runtime.run(Runtime.java:81) at cucumber.api.cli.Main.run(Main.java:26) at cucumber.api.cli.Main.main(Main.java:8) at ✽.I receive a home aggregator decline code of 2(C:/git/qa-api/src/main/resources/features/Feature.feature:10)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
thomhurstcommented, Nov 15, 2018

And for cucumber-core?

Right now your stack trace is going through through:

https://github.com/cucumber/cucumber-jvm/blob/v4.1.1/java8/src/main/java/cucumber/runtime/java8/Java8StepDefinition.java#L93

And then fails to call:

https://github.com/cucumber/cucumber-jvm/blob/v4.1.1/core/src/main/java/io/cucumber/stepexpression/ExpressionArgumentMatcher.java#L18

So the method is there. Which makes me believe you have a problem on your end.

If you can provide an mcve I can look into it further.

Sorry @mpkorstanje - It was Maven. It had downloaded a corrupted 4.2.0 and so half the classes weren’t resolving. I’ve cleared my local maven, redownloaded and it’s all good now. Thanks and sorry!

0reactions
lock[bot]commented, Nov 15, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Undefined step reference InteliJ + Cucumber for Java + ...
1 Answer 1 ... First two messages are just warnings - because you created Steps class, but didn't use it (and, of course,...
Read more >
Step Definitions - Cucumber Documentation
A Step Definition is a Java method Kotlin function Scala function JavaScript function Ruby block with an expression that links it to one...
Read more >
Create step definitions | IntelliJ IDEA Documentation - JetBrains
Select Java 8 to use lambda expressions in step definitions or Java to use annotations. Note that files with step definitions should be...
Read more >
A Practical Example of Cucumber's Step Definitions in Java
When writing Cucumber tests in Java, it's common to use the Step Definition class to keep ... Later, we refer to the user...
Read more >
Cucumber Undefined Step Reference In Intellij - ADocLib
In Rubymine my Aruba steps show up as 'undefined step reference'. Also make sure that your edition of IntelliJ IDEA supports the language...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found