Why is unit testing so important?

Let's have a real-life example. Think of an engineer, creating a new motor or device. The engineer will test the functionality after completing each unit of that motor, rather than testing the whole motor at the end (though he / she will test the whole motor at the end, but will also test it repeatedly and incrementally while building it). The main reason behind this behavior is that if he / she doesn't do that, at the end it would take a lot effort to identify the exact problems (if any). While testing incrementally will allow you to fix any problem right away as soon as it arises. The same applies for software (applications) as well.

You should perform unit tests periodically and repeatedly as you develop each module of your application the more you test the better is the out product. And yes, we should write unit tests for each and every functional section of our applications.

By functional section we mean each section that performs any small operation and/or function. We can skip testing a POJO class with just getters and setters, but we must test the code which uses that POJO class to accomplish something.

So, as we've understood the importance of testing, let's start by writing JUnit tests in Kotlin.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.71.21