GithubHelp home page GithubHelp logo

Comments (6)

aslakhellesoy avatar aslakhellesoy commented on July 1, 2024

In cuke4duke/java, step definitions are plain old java methods. You can just invoke the method directly. If the method is on another step definition class, just declare a dependency on that class in your constructor, and picocontainer will pass it in when the step definition object in instantiated. If you're using spring, just declare dependencies between step definition classes using regular spring DI techniques.

Does this answer your question?

from cuke4duke.

epabst avatar epabst commented on July 1, 2024

The problem is that I have several steps that might need to be delegated to, and I'd like to use the regular expression matching logic to determine which one, parse the remaining string correctly, and call the method. For example, I have the following possible strings:

a birth of "10 Jan 1959" w/o a place
a marriage-like event of "5 May 2000" in "Paris, France"
a graduation event w/o a date in "Atlanta, GA"
...

I'd like to be able to match "(a (?:birth|.event)) in "(.?)"" and have it figure out the place, and delegate to whatever matches group 1. In Ruby, it's totally straightforward to do that, but in Java, it doesn't seem possible.

from cuke4duke.

aslakhellesoy avatar aslakhellesoy commented on July 1, 2024

I see. So you want to call-by-string, and have Cucumber pick the right one for you? You need to do that via a method (let's assume we had a Given(String step) and similar When ant Then methods).

This could be on a superclass, or it could be on a special object that your step def class could get a ref to via DI. I like DI better than inheritance.

So what if you could do this:

@Given("foo")
public void foo(String theFoo) {
    this.steps.Given("Ping " + theFoo);
    this.steps.Given("Pong " + theFoo);
}

Is this what you're after?

from cuke4duke.

epabst avatar epabst commented on July 1, 2024

Yes! That would be perfect. :)

from cuke4duke.

aslakhellesoy avatar aslakhellesoy commented on July 1, 2024

Enable Java step definitions to call other steps indirectly by just providing a string. Closed by 6a88501

from cuke4duke.

aslakhellesoy avatar aslakhellesoy commented on July 1, 2024

Wiki updated: http://wiki.github.com/aslakhellesoy/cuke4duke/calling-steps-from-stepdefinitions

from cuke4duke.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.