Tests are very important part of every app, I proved it here. There are different ways of testing your application but today I want to focus on acceptance tests - without technical details this time.

High-level interaction

While unit tests are focused on a low level of interaction, acceptance tests are focused on a high level of interaction. What does it mean? If you have a guestbook application you may want to test the following scenario: user inputs comment and invalid email address, the user submits a form, user see an error message - you test the process and the way an app is working from the perspective of the user. If you would want to test the same scenario using unit tests you would probably start with testing class responsible for email validation or controller responsible for receiving and processing the user request.

Want to receive useful tips, information about new Ruby gems and articles on a daily basis? Make sure you follow me and say hello!

Are unit tests are not enough?

Yes and no. If you have the time it’s always worth to write acceptance tests at least tests for a happy path. Happy path means that you test only success scenarios. In a previous example you would test only following case: user inputs comment and email, the user submits a form, user see a successful message. You would omit cases for invalid or blank email, blank comment etc.

Start with unit tests

If you are just starting your journey with tests, I highly recommend familiarizing with unit testing first. It’s obvious that we should always focus on ensuring that low level of interaction is built correctly because strong fundamentals are the most important thing for everything you do - without this, you build the most beautiful app but it may fall down one day after adding one small change to existing code.

Want to become a better Rails developer?
Download for free the Introduction Rails patterns book and dive into the world of refactoring and easy-testable Ruby code today.
Join over 1,000 developers already subscribed to my newsletter and download the book. You can unsubscribe anytime:

Subscribe and get the book!