Is it possible to programmatically inject custom code into the generated step definition method?

13 views
Skip to first unread message

wayne

unread,
Sep 10, 2017, 4:33:29 AM9/10/17
to Cukes
When I run a cucumber test against a feature file that has a new step such as the following:

Given This is a test with "argument 1"

The test will fail and the following code snippet will be generated:

@Given("^This is a test with \"([^\"]*)\"$")
public void this_is_a_test_with(String arg1) throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

I already know the code that should go into this step definition method.  Instead of manually putting it in, is there a way to inject the code programmatically?  The motivation is that there could be a lot of new steps (and I already know the code each new step should be calling).  


aslak hellesoy

unread,
Sep 10, 2017, 8:22:52 AM9/10/17
to cu...@googlegroups.com
There isn't.

If there was a way, how would you like to tell Cucumber what file to edit?

Aslak

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eric Kessler

unread,
Sep 10, 2017, 1:08:19 PM9/10/17
to Cukes
How do you already know the code that you are going to use? 

Reply all
Reply to author
Forward
0 new messages