Unit Testing

Hello dear readers. Today I am going to talk about Unit Testing. I believe most of the people are pretty familiar with it, but for those of you who are not : Welcome to What is Unit testing and why to use it!
Unit testing is a testing process where the smallest part of a program or an application are tested individually. A unit can be almost anything you want it to be — a line of code, a method, or a class. Generally, smaller is better. Smaller tests give you a much more granular view of how your code is performing. There is also the practical aspect that when you test very small units, your tests can be run fast; like a thousand tests in a second fast. Unit testing involves only those characteristics that are important to the performance of the unit under test. This encourages developers to modify the source code without worrying about how such changes might affect the functioning of other units or the whole program. Once all of the units in a program have been found to be working in the most efficient and error-free manner possible, larger components of the program can be evaluated by means of integration testing.

Unit testing is performed by using the White Box Testing method. When creating Unit test we should keep in mind not to create test cases for everything. Focusing on the tests that impact the behavior of the system is the most important. Another issue that is usually very common in software testing is debugging and unit testing makes it easier. When a test fails, only the latest changes need to be debugged. With testing at higher levels, changes made over the span of several days/weeks/months need to be scanned.

Unit testing also increases the confidence in maintaining/changing the code. When these unit test run after the code is changed, will be able to promptly catch any defects coming from the changes made.

To be honest Unit testing is probably my favorite way of testing. Of course, as a tester Unit testing is not efficient for lots of code and other ways need to be consider. However, the reason why I like Unit testing is because it helps you figure out where the defect is in the code. The changes of a defect persisting are higher when not using a unit test and if you try to fix it you can break something else.  Also, it is good to write tests before trying to fix it because if you fix it right away you will be lazy to write tests anyways. And keep in mind test coverage has to be as high as possible! ALWAYS!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s