DEV Community

Discussion on: Need help in Integration testing ruby

Collapse
 
derekjhopper profile image
Derek Hopper

People will often reach for Capybara to do integration testing.

Like you mentioned, integration tests can be slow. One thing that's helped me over the years is to make sure you're using the correct driver. For example, if you don't need the JavaScript driver, try not to use it. If you're using Capybara + Rspec, the JavaScript driver is enabled by the js: true flag. In my experience, these tests will always run slower because it spins up a full browser instance. If you're using the JavaScript driver needlessly, you'll bloat your test suite when you don't really need to.

In other projects, I've had good luck using chromedriver (github.com/flavorjones/chromedrive...). You can run it in headless mode. It feels much faster than webdriver + Firefox. I have a small web app covered almost 100% by integration tests and I don't feel like it's too slow.

Test driven development is a huge subject. Just remember integration testing is just part of it. It's helpful to use integration tests, but it doesn't have to be your whole test suite. You can also do separate runs of unit tests and integration tests. If your unit tests fail, you know something is wrong and you don't have to run the integration tests.