Consider this, you need to implement a new feature into the current application. You should test all the cases again "manually, individually". At this time, you may forget one bad case.
Needles to say, there are a few problems with your testing;
- Takes time to test all cases
- It's manually tested
- It's not repeatable
- It's not reusable
- Nobody know what you test
In order to test your application you should be familiar unit testing approaches. For instance what is "unit" in test term? Let's explain some terms you need to understand clearly.
Unit : A unit is a piece of code of your application which is testable.
Unit Test: A unit test is a method which invokes another piece of code and test to determine whether they are correct according to some assumptions.
Integration Testing : Testing one or more than one modules as a group. It occurs after unit testing.
Refactoring : You will face this term if you use unit testing. Refactoring means changing code without changing its functionality. If you separate any method into smaller methods or change existing method name you did refactoring. The main aim of refactoring is to make the code become easier to maintain, read, change and test.
In order to do successful unit testing you should take into account these rules :
- Your unit testing should be easy to implement
- Your unit testing should run quickly. When you start your unit testing it should be finish as soon as possible
- Anyone in your team can run unit testing you write is able to run
- It should be reusable
- You should design your test code to be run automatically
- When you write your test code, it should remain for future use
Actually, before writing unit test, your software application should be designed having regard to test driven development. In order to write good unit testing, you should know software design principles which led you to create useful unit testing. Beside this, you need to know some design patterns such as dependency injection pattern or factory design pattern.
