[LRUG] Writing readable feature tests with RSpec

Murray Steele murray.steele at gmail.com
Sat Jul 26 03:10:00 PDT 2014


On 26 July 2014 01:24, Andrew Premdas <apremdas at gmail.com> wrote:
>
> On 25 July 2014 11:46, Murray Steele <murray.steele at gmail.com> wrote:
>
>> I like cucumber because of how it makes me think about what the user
>> journey I’m testing is actually about and for, but I dislike cucumber
>> because I think the regexp matching for step definitions places an
>> unnecessary burden on the developer.
>>
>
> This is really unfortunate. The fact that regex's are there in Cucumber
> means that you 'can' do all sorts of stupid things with them. If you do
> that will be a burden. However it doesn't mean you should do this or have
> to do this. 50% of my step definitions have no parameters at all, and I
> suspect less than 3% have more then one parameter.
>

To be fair to cucumber this is how I ended up using cucumber in my last
outings with it and it was much nicer to use.  I learned a lot about how to
write acceptance/integration specs from doing cucumber the right way.

We don't criticize Ruby for allowing us to write stupid code, but it seems
> that we expect Cucumber to do more.
>

Sure.  I think a large part of the problem here is that well written
application code exhibits different qualities than well-written test code.
 For example duplication is usually bad in application code as it means a
bug can surface in multiple places but only be fixed in one.  However in
test-code lots of DRYing up can make the tests harder to read and for me
readability of tests is one of the most important qualities.

For all the different ways we can write bad cucumber, we can do the same
things with rspec features.  The fact that we’re even writing articles
about how to write rspec features in a (to me at least) clearer style
suggests that there are plenty of rspec features out there written in
styles that aren’t so useful.

I think well written cucumber is a good tool, and I’d rather have well
written cucumber on a project than badly written rspec features.  All else
being equal though, I’ll reach for rspec features.

Cheers,

Murray
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20140726/d3f7647c/attachment-0003.html>


More information about the Chat mailing list