Ruby on Rails testing

Rails / Testing – acceptance tests

Rails / Testing – acceptance tests January 7, 2018Leave a comment
Acceptance tests

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.

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.

Having problems with tests for your Ruby on Rails application?

Hit me on twitter or use contact form and let me know how can I help you!

Image source: pexels.com

Download free RSpec & TDD ebook

Do you want to earn more or jump to the next level in your company? Do you know that testing skills are one of the most desired skills? There is only first step: start testing and do it right. My ebook can help you. Subscribe to the newsletter to get a free copy of the book.

Leave a Reply

Your email address will not be published. Required fields are marked *