I have been using TDD for Development recently. I have realized that the shortcomings of TDD really affect the development progress. However, I have also realized that it is an excellent aspect of TDD, that is, to let the problem emerge earlier and to rebuild it.CodeYou are also very confident. In fact, mostProgramThey are very confident in their writing capabilities, and think that there are few defects in writing code. However, the actual situation is that most of the defects will be exposed later in development. This is also one of the main reasons for our programmers to work overtime every day. A very simple example:
Int add (int A, int B ){
Return A + B;
}
What is the problem with this function? It is very simple as an addition. OK. We may have considered integer overflow, but when our project is busy, we may have thrown such code into the product. After one day, I found that the program ran and traced it for half a day. Oh, it turned out to be here, and I hate it. Obviously this is not a good method, so we should spend more time on unit testing to reduce the number of overtime work. For the above example, we can change the return value to the long type. Sometimes testing is really hard to write, such as databases, multithreading, network access, etc. But there is always a way to do it, as long as you don't want to do it.