Early in the morning, a young programmer asked the master:
"I'm going to write some unit test cases. How much code coverage should be achieved ?"
The master replied:
"Do not consider code coverage. Just write some good test cases ."
Young programmers are very happy to bow and leave.
Not long afterwards, the second programmer asked the master the same question.
The master pointed to the boiling water in a pot and said:
"How many meters should I put in this pot ?"
The programmer seems to be stuck, and replied:
"How can I get an answer? It depends on how many people they want to eat, whether they are hungry, what food they have, how many meters you have, and so on ."
"Completely correct," said the master.
The second programmer is very happy to bow and leave.
Finally, the third programmer asked the master about code coverage.
"80%, not less !" The master hammers at the table and answers in a harsh tone.
The third programmer is very happy to bow and leave.
After replying to this question, a young intern came to the master's side:
"Master, today I accidentally heard you give three different answers to the same code coverage issue. Why ?"
The master stood up from the Chair:
"Bring me some new tea. Let's talk about it ."
When the cup filled with hot green tea, the master began to say:
"The first programmer is a newbie. He just started learning the test. Currently, he has no test cases for a large number of programs. He has a long way to go; now it is useless to require code coverage to only hit him. It is best to let him learn to write some test cases and test them. He can consider code coverage later ."
"The second programmer, both programming and testing, is very experienced. I asked her how many meters she should put in the pot, so that she could understand that there are many factors that determine the number of test cases, she knows these factors better than me-after all, it's her own code. There is no simple and direct answer to this question. With her cleverness, she can fully understand this truth and complete the task correctly ."
"I understand," said the young intern. "But if there is no simple and direct answer, why do you tell the third programmer '100, no shares ?"
The master smiled and sprayed green tea.
"The third programmer only wants a simple answer-even if there is no simple answer... And even if there is an answer, she will not do it according to the answer ."
Young interns and white-haired masters finish tea in meditation.
Http://blog.csdn.net/metababy