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.
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?
Image source: pexels.com