Unit test:
Why do we need to perform unit tests?
Introducing unit tests is simple because it is fun. However, during project delivery, we still provide products to customers and end users.CodeAnd does not contain unit test code. Therefore, we must have a full understanding of the purpose of unit test. First and foremost, unit testing is used to make your work-and the work of your teammates-easier.
Is it a waste of time to write unit tests that increase coding time?
If you still think that you still don't have time to write test code when writing product code, consider the following questions:
1. How much time have you spent on debugging the written code?
2. How much time have you spent reverifying the code that you thought was correct before, but in fact there are major bugs in the code?
3. How much time have you spent on finding the source code location of a bug reported by someone else?
Advantages of unit testing?
Promptly discover problems
In the long run, the cost of using the "test model now" is lower than that of the "test model later. When writing the implementation code, you can write independent test code at the same time to avoid useless problems at the end of the project.BugEven less, because you are dependent on code that has passed the test. Therefore, by spending more time writing unit tests during the development process, you can minimize the risk of spending a lot of time in the later stages of the project.