Last week, I was in a bad mood. This was a good week. The first thought was especially fast! Clearly remember to report the shortage of 50 percent to Ed, but now it's over a week. Of course it can be said that it's not over. After all, there are two days of the weekend!
Just putCodeThe upload also marks the end of another N-percent: The test passes successfully and feels comfortable. No matter what the project is, briefly describe the experience of TDD.
Yesterday, I spent some time combining my own TDD practices with the theory of <test driver development> by Kent Beck!
Why is there a problem in the regression of many tests in the early stage? Because we did not fully realize the importance of test decoupling when writing tests. therefore, when we run all tests in a regression mode, there is an inconsistency in sequence, resulting in insufficient data preparation or data violations, this leads to a terrible red progress!
Remember! ---- The test must be completely decoupled to form an independent test! Only
When writing a test without coupling, you can understand what loose coupling and high cohesion!
How can we let the test drive you to write code? TDD requires us to write the test code first and then write the implementation! My understanding of this is the same as that of many people: How can I write and test without code? But in fact, there are two important reasons: First, we didn't actually do it; second, we relied too much on IDE. first, there seems to be nothing to say. If you do it, you will know that it is okay. second, we are used to the smart perception or prompt function of the development environment. however, when writing a test, you will not enjoy the "comfort" to a certain extent. because the code has not yet been formed, it cannot provide support for your test!
Following some principles of TDD will make youProgramI am more confident. I have started to understand this point. :) I will submit all the questions for a test to tell me that when there is a red progress, I will know that there is a problem here, if it is all green, I will be very solid: The pressure is much lower! If you can use todolist to complete the task, it feels great!
In TDD, there is a relationship between testing and stress:
1. you don't need TDD. When the stress is high, you will run less and less tests because you need to catch up with the progress. if TDD is used, the more stress the test is, the more you will run the test, because only after the test passes will your work be completed.
It can be said that the pressure is acting on the test. as you run more and more tests, you will become more and more confident. currently, the test code runs for a short period of time. Therefore, I ran the test every 10 minutes. I felt much better when I saw the green pass!
TDD requires "small steps and fast" to split large functions into small-scale tests again and again, so that it can be passed and then tested or reconstructed on a larger scale. after each refactoring, we need to test whether your refactoring has caused damage! Although currently there are not many code refactoring methods, mainly parameter and method-level refactoring (My definition), after refactoring and passing the test, I am very relieved with the previous actions!
Finally, write down several questions:
1. I violated a very important principle: Don't comment out the test code and let the test pass. I did it and regret ing!
2. Test is preferred. You must write a test before making any changes or restructuring. This is a bit difficult to meet your own habits, so I made a mistake! Correct ing!
3. I have not learned how to use mock for testing. Mock is useless because of the low overhead of the current testing. It may not be a problem, but I have to record it!
4. There is no real todolist. This is a habit problem. Cultivate ing! ----- It can increase confidence!
During this week, I spent most of my time writing tests and passing tests! Finally, I felt its charm and strength! By the way, debugging is always very painful in any situation!
What should I do if my appetite is poor recently?
Attach a photo of the super "charming girl" found today (Zhu Liye-bioxuyu)
Welcome to: http://hi.baidu.com/flyingchen