"Foreign periodicals It Review" code coverage: 80%, no less

Source: Internet
Author: User

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:

"Don't consider code coverage, just write some good test cases." ”

The young programmer was delighted, bowed and departed.

Not long after, the second programmer asked the master the same question.

The master pointed to a pot of boiling water and said:

"How many meters should I put into this pot?" ”

The programmer looked puzzled and replied:

"How could I have the answer." It depends on how many people you want to eat, whether they are hungry, what food you have, how many meters you have, and so on. ”

"Absolutely right," said the master.

The second programmer was delighted, bowed and departed.

Finally, the third programmer asked the master the same question about code coverage.

"80%, not less." The master punched the hammer on the table and replied in a stern tone.

The third programmer was delighted, bowed and departed.

After replying to this, a young intern came to the master's side:

"Master, I overheard you today." You have three different answers to the same code coverage issue. Why. ”

The master stood up from the chair:

"Give me some tea, let's talk about this." ”

When the cup was filled with steaming green tea, the master began to say:

"The first programmer was a novice and was just beginning to learn the test. Currently he has a large number of programs that do not have test cases. He has a long way to go, and now it is useless to ask him for code coverage to hit him. It is better to let him slowly learn to write some test cases, test it. He can consider code coverage later. ”

"And this second programmer is very experienced in both programming and testing. 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, and she knows these factors more than I do-after all, her own code. There is no simple, straightforward 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 straightforward answer, why do you tell the third programmer ' 80%, not less '? ”

The master laughed and the green tea was blown out.

"This third programmer only wants a simple answer-even if there is no simple answer ... And even if there is an answer, she will not follow the answer. ”

Young interns and grizzled masters drank tea in contemplation.

Http://blog.csdn.net/metababy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.