Code self-test

xiaoxiao2021-03-06  58

The code self-test is a process that must be performed before the code is moved, and it is actually a category of white box test.

There are generally two ways: 1. Write unit tests and guarantee the test. This method is the best, and it is also the direction we have to work in the future. However, the current gcl7.calculator is in the maintenance phase, and the previous design cannot support write unit tests well, so it is not easy to implement it. I have done some attempts, I have time to introduce it to everyone. If you are interested, you can explore it. 2. In the debug state, STEP is from the Writing Solid Code. Before learning to write unit test, it is my main self-test means. Be sure to ensure that your code is STEP, and you carefully check the status of each step in line with your expectations. (Did you do this, do you dare to have confidence in your code?) The key point of this method is to force you to construct a test case, let your code have been overwritten (of course, not requiring overwriting all logic Combination, it is difficult to do, and it is not necessary for the system we do).

This method sounds difficult, in fact, because you will not be too big every time you move, it is easier to implement (as long as you have enough responsibility for your own code). At the same time, this method can help you develop a habit that often moves into the code.

Note: Writing Solid code, Chinese version is "Programming Jing - Microsoft Writing Quality Whenever Cable C", with electronic version.

转载请注明原文地址:https://www.9cbs.com/read-114615.html

New Post(0)