> I have been impressed with what I have seen of Cucumber so far. I am
> interested in using it to test some PHP applications. I started
> setting up Cucumber with Cuke4PHP but have now reached a point where I
> need to better understand Cucumber and some BDD philosophies before I
> can go any further.
>
> I think I understand how to use Cucumber for writing Selenium tests.
> Our team has a bunch of brittle Selenium tests written in PHP that I
> would like to replace. Actually, our team only has Selenium tests (not
> even any unit tests). The part I don't understand that well is setting
> up test data. What are some best practice approaches to creating/
> deleting test data and running the application using that test data?
I don't like the term 'best practice' but I'll tell you what has worked for me, and some things I've seen other people do that have made them struggle.
Wheras with manual test scripts, you might have had one scenario build on the data from another, Cucumber is designed to reset the state of the system between each scenario. This helps your tests be less brittle, because changing one scenario doesn't affect the data that will be seen by another. Each scenario is thus responsible for setting up the data that it needs. This makes tests easier to read, because all of the state for the scenario can be seen in your Given steps.
The down-side of this is that, if you have a complex schema, you can find yourself needing to set up a lot of test data to get to 'ground zero' during each scenario. This can make your tests slow. I've generally found this is a price worth paying for reliable tests.
Also, you can end up with a lot of noise in your Given steps. For example, if you're testing an application that requires every user to be authenticated, it's pointless to specify, in every single scenario Given I have a valid account And I am logged in etc. You're better off doing that implicitly with a hook (see Cucumber's Wiki).
I don't have time to write more now, but hopefully that helps.
> Another part I don't understand is how Cucumber works outside of the
> context of Selenium. Also, being new to Ruby, I'm not sure I
> understand what RSpec is for and how it ties in to using Cucumber.
> Also...should I be thinking about using Cucumber as a wrapper for unit
> tests as well?
In Cucumber, RSpec is basically used for assertions. Ruby people who use Cucumber tend to also be RSpec users, but you don't need to use RSpec with Cucumber. You can use any assertion library you like.
I would avoid the temptation to use Cucumber for unit tests. In my experience, testing works best with a two-layer combination of end-to-end tests (e.g. Cucumber) that prove you're building the right thing, and low-level unit tests (e.g. RSpec) that prove you're building the thing right. These tests are for different audiences and so suit different tools.
> Thanks,
> Andrew
cheers,
Matt
ma...@mattwynne.net
07974 430184
> I have been impressed with what I have seen of Cucumber so far. I am
> interested in using it to test some PHP applications. I started
> setting up Cucumber with Cuke4PHP but have now reached a point where I
> need to better understand Cucumber and some BDD philosophies before I
> can go any further.
>
I don't have time to give philosophical advice today, just thought I'd point out
You may want to compare it with Cuke4PHP.
Aslak
> I think I understand how to use Cucumber for writing Selenium tests.
> Our team has a bunch of brittle Selenium tests written in PHP that I
> would like to replace. Actually, our team only has Selenium tests (not
> even any unit tests). The part I don't understand that well is setting
> up test data. What are some best practice approaches to creating/
> deleting test data and running the application using that test data?
>
> Another part I don't understand is how Cucumber works outside of the
> context of Selenium. Also, being new to Ruby, I'm not sure I
> understand what RSpec is for and how it ties in to using Cucumber.
> Also...should I be thinking about using Cucumber as a wrapper for unit
> tests as well?
>
> Thanks,
> Andrew
>
> --
> 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 http://groups.google.com/group/cukes?hl=en.
>
Thanks for the advice! Probably my biggest question I still have is
this: Can/should Cucumber be used by itself to test a PHP web app, or
do I need to/should I use Webrat, Capybara, Watir, Celerity, Culerity,
etc? (I don't fully understand the purpose of all these other
projects, the headless browser idea, and how/if it would work to test
a PHP app). I understand how Selenium works because I've used it
before (outside of Cucumber). Any advice/clarification would be much
appreciated.
Thanks!