Discussion:
[Cucumber] Is it possible to programmatically inject custom code into the generated step definition method?
(too old to reply)
wayne
2017-09-08 20:57:59 UTC
Permalink
Raw Message
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).
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
aslak hellesoy
2017-09-10 12:22:35 UTC
Permalink
Raw Message
Post by wayne
When I run a cucumber test against a feature file that has a new step such
Given This is a test with "argument 1"
@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).
There isn't.

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

Aslak
Post by wayne
--
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
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Eric Kessler
2017-09-10 17:08:19 UTC
Permalink
Raw Message
Post by wayne
When I run a cucumber test against a feature file that has a new step such
Given This is a test with "argument 1"
@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).
How do you already know the code that you are going to use?
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...