January 11, 2011 06:19
Posted by Jeremy Durham
There is no Holy Grail
Regardless of what Monty Python or Indiana Jones might have us believe, or not believe, there is no Holy Grail. In our case, the Holy Grail is the ability to run browser based Cucumber tests expediently. We’ve been chasing the Holy Grail for some time, and it ends today.
We started using Cucumber as we got more involved in the agile process. Unfortunately, like most other people, we were unable to catch our unicorn, and we never got our “customers” to write acceptance tests. Considering that we mainly do work for the government, I suppose we couldn’t expect to really have a lot of success getting them to write acceptance tests, but we subscribed to the process. The road was paved with good intentions.
How did it all go so wrong? As with many tools, we began to lean heavily on Cucumber. Our model, controller, and view specs started to be neglected, mainly as we spent serious amounts of time trying to get our javascript tests to run. Basically, very little of our applications will function without JavaScript.
The time we spent writing Cucumber features paled in comparison to the time we spent running Cucumber features. I previously blogged about my attempts to mitigate the issue. We now have another project that has hit 30 minutes per build. Obviously, we are in a unique situation and if you can keep your JavaScript tests down to <5 minutes, Cucumber + Selenium is probably fine and you should continue what you’re doing.
Recently, something snapped. Ben mentioned that his friend had rejected Cucumber and exclusively written view specs with graceful degradation. I respect the merits of doing that, but it can be difficult to sell the idea of building functionality in such a way that it will never be used, or specifically for testing purposes.
After a series of conversations, we’ve come up with a good direction. Our intention is to give more time to model and controller specs, use view specs or cucumber without selenium to test our views, and Jasmine to test our JavaScript. We’ll probably even mix in a bit more (GASP) manual testing, at least for the time being. With the time we save not writing javascript tests and running the full hour plus test suite, we’ll should have additional time to invest in researching other testing tools and strategies as well.
Ultimately, we’d love to increase our test coverage and validity, decrease our test running time, and as a by-product increase developer happiness. There’s nothing more demoralizing than finishing a feature, only to have to wait an hour or so to be able to push it and start on your next one. Ideally we’ll return to the days where running tests 50-100 times a day is not unrealistic. Right now, we’re lucky to run the full suite 5-6 times a day.
Cucumber, you’ve been good to us, and although you probably won’t be going away completely, it feels like the end of an era. Hopefully the next phase will bring faster builds and better tests. I’m happy we’re ending our quest for the Holy Grail, and although we’re not holding the Holy Grail in our hands, we’re more knowledgeable and ready to move on.
2 Comments
January 11, 2011
Coming from an outside perspective, I found Cucumber more clever than useful. Abstracting “close to the metal” instructions for readable tests just felt too abstract to be useful. I decided to see how it would pan out but my opinion never swayed. The work often involved writing custom steps, and I couldn’t get over the false positives, timeouts, and time wasted waiting for tests to complete.
I think that browser simulation testing is just a little ahead of its time. Headless browsers, and browsers in memory exist, but none of them integrate in a mainstream Javascript engine. Whats worse, is that the quality of testing provided for alternate browsers gets worse outside of Firefox. If the speed were the same, Cucumber might be a lot more attractive.
Final thoughts: Its naive to ever think any testing can completely cover a project. Cucumber doesn’t check things like CSS, browser quirks, human interaction, etc. There will always be the next sigma to try and encompass from a testability standpoint, with an exponentially increasing cost. Technology isn’t always the answer to these types of questions.
July 21, 2011
We use Cucumber + RSpec extensively for our projects. Our flag-ship app takes about 90 minutes to fully test on a mac pro running continuous integration with Jenkins. But on the development computers we run the tests in small chunks/profiles. So almost every profile (mostly a specific feature/branch inside the project) takes max 10 minutes to test completely. We also try to keep every feature file small and clean, making them fast to run.
Running tests always take time, but having a full test run a few minutes and having a good cup of coffee is far more productive than running every stupid test manually… especially for webapps that require you to login, browse to that specific page, execute whatever is needed and wait for the result… puke :)
Leave a comment