Unit tests

Unit tests are tests that you can write while developing a new feature, fixing an issue or refactoring the code. You can use these tests to ensure the code behaves the way you would like it to behave, with tests in place you can feel more safe to change code's structure to a more readable one.

There are some benefits: 

  • Improve the quality of what you deliver.
  • Optimize your time, since you no longer have to manual test the same thing over and over again.
  • Make it easier for the next person that will work with the same code

The cruel reality

  • Unit testing the code won't make it bug-free, but it will probably reduce defects.
  • It is easy to give up and just write code without tests, since it demands time and thinking to write.
  • It is hard to write tests for legacy code. You have to learn how to break dependencies without breaking the code, but when you start learning, you improve a lot.

Unit testing the code, generally, results in better code structure

TRUEFALSE

CORRECT

You're right, this statement is TRUE!

It is hard to write tests for a large unit of code that has a lot of different responsibilities. Writing tests, generally, makes you write more modular code which is easier to understand and maintain.

← Back to the question

INCORRECT

Sorry, this statement is not false, it is TRUE!

It is hard to write tests for a large unit of code that has a lot of different responsibilities. Writing tests, generally, makes you write more modular code which is easier to understand and maintain.

← Back to the question

We can trust 100% in unit tests. If they are passing, our code works.

TRUEFALSE

You're right, this statement is False!

Our unit tests, like our code, will probably have bugs, details that we forgot, scenarios that we didn't think of. We have to always pay attention when we code, even with tests in place.

← Back to the question

Sorry, this statement is not true. It is FALSE!

Our unit tests, like our code, will probably have bugs, details that we forgot, scenarios that we didn't think of. We have to always pay attention when we code, even with tests in place.

← Back to the question

What we can conclude from this content is that unit testing will help you to deliver better quality work, but you have to consistently work hard to continue on this way of always trying to improve quality and don't give up.

Did you enjoy this infographic?

Fill out this short form and someone will be in touch with you shortly.