Hacker News new | ask | show | jobs
by dschwartz88 4533 days ago
We have three layers of testing in our suite. Ill go from the bottom up (we happen to be a rails shop so use rspec + Capybara):

1. Model Tests: These are used to validate base business logic. This is for things like totaling up order values, making sure discounts are applying correctly, and making sure taxes are being correctly applied. These in my opinion are the tests you must have. If you're not validating your base business logic theres no way to prove your other testing suites are doing their job. These are done for both Ruby code (rspec) and Javascript code (using Jasmine)

2. Controller/API Tests: These are to validate that different parts of the business logic working together actually do what is intended. When a user places an order lots of things must happen (I need to charge them, I need to send them an email, etc.). These are done in rspec and are a nice way of validating things in an orchestration style API (vs. a REST style API).

3. Selenium/Acceptance Testing: These are super important. These actually automate what a real user is going to be doing on your site. We test both Admin and normal user flows. These are the easiest to write and give some of the biggest wins. These will catch bugs your users are actually going to encounter. Having model and controller tests for something like checkout are necessary but they must be augmented with acceptance tests or else you can't be sure something else isn't holding up your user from checking out.

Our entire test suite runs on CircleCI (love those guys) but could technically be run on almost any platform (we ran Jenkins for a bit too). Hope this helps. Feel free to ask any questions!

1 comments

for the acceptance testing, how often do you run it? just curious. I found selenium to be unreliable and just stopped itself for no reason after running for a couple of hours.