[Cucumber] dynamically create cucumber steps from scenario outline step_definition

1,297 views
Skip to first unread message

Yasir

unread,
Jul 17, 2013, 8:50:41 AM7/17/13
to cu...@googlegroups.com
Hi,
  My application is data intensive. What data values to test is also dynamic. Rather than try to save the dynamic data into static files and over complicate the data maintain in fixtures and make test scenarios more static. I wonder if any one of the following is possible:

1. Is it possible to pass a new step and or result that look like a step to cucumber layer, from the ruby code (which is part of step definition)?


- Note: I want to use the cucumber reporting of steps pass/fail, at the same time not trying to create unnecessary static data. In my case steps are more correspond to the behavior of the system and data validation is dynamic. Data validation step can have many individual data_elements tested in it, if I can pass each one of those data_element result to cucumber as pass/fail that would be ideal. That way cucumber layer reporting would be sufficient for me. Rather than I have my own reporting for data_elements.


Thanks,
Yasir. 

Andrew Premdas

unread,
Jul 17, 2013, 9:13:53 AM7/17/13
to cu...@googlegroups.com
You can't take the approach you described, however the following might meet your needs

1. Write a step def to use the do the dynamic validation and collect the results in an object (say @results)
2. Write a "Then" step, something like 

   Then 'the results should be good' do
      @results.report unless results.good?
   end

3. Implement the good and report mechanisms as appropriate to your needs.


Whenever you want to do something unusual with Cucumber look at pushing the functionality DOWN into the step definitions where you can use the full power of a programming language to do anything.

HTH

Andrew


 
--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
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/groups/opt_out.
 
 



--
------------------------
Andrew Premdas

Yasir

unread,
Jul 17, 2013, 9:53:46 AM7/17/13
to cu...@googlegroups.com
Andrew, 
  Thanks for the reply. I am doing something similar to what you described. I want to reconcile the @results (my data validation) and cucumber (scenarios and steps result summary) output result in a unified report. Does that mean I have to create a custom formatter? - Can you pass objects to a customer formatter from step_definition?

Thanks.
Yasir.  

Andrew Premdas

unread,
Jul 17, 2013, 10:51:54 AM7/17/13
to cu...@googlegroups.com
Yasir, please do not top post


On 17 July 2013 14:53, Yasir <yasi...@gmail.com> wrote:
Andrew, 
  Thanks for the reply. I am doing something similar to what you described. I want to reconcile the @results (my data validation) and cucumber (scenarios and steps result summary) output result in a unified report. Does that mean I have to create a custom formatter? - Can you pass objects to a customer formatter from step_definition?

You could try getting your step def to print to stdout/stderr first and see if that works. Going further than that is something I don't know about.
Reply all
Reply to author
Forward
0 new messages