Sunday 22 April 2012

Why not to test everything with Capybara

Firstly, I like Capybara. I think it is nice how easy it is to test with just a few verbs, and you can do things from the perspective of the user. It is no good having the back end for a feature if nobody is ever going to click the button to make it happen. I decided to try do an entire project using just Capybara for testing.

However this comes at a price. Each assertion restarts Rails Server.
This is VERY slow for lots of tests to the point where each test takes about 2 seconds in my current project.

I suppose a drawback some people might make is my tests are tightly bound to the actual view which is another drawback of using Capybara.

Yet another issue I am hitting is organization, all my Capybara tests end up in the same Requests folder which is quite naughty of me.

So, Capybara is slow on many assertions, it links you to the way you display information, and it makes me personally use a disorganised file structure.
Conclusion is I should not use entirely Capybara for the entire project testing. I really need to mix Rspec in there with occasional sprinkles of Capybara.

No comments:

Post a Comment