What is test-driven development?

Source: Internet
Author: User

After several days of observation, I found that many comrades have not yet understood what is "test-driven development ": what is the purpose of the test written before development-the reason for saying "surprise" is that there are both "surprises" and "surprises ". I will explain a little about the problems I encountered in my recent university lectures.

(Discussed earlier:
Http://forum.javaeye.com/viewtopic.php? T = 19959
Http://forum.javaeye.com/viewtopic.php? T = 20035)

The name of "test-driven development" should first be clear: it corresponds to "document-driven development ". It is a development process. The test here is a design issue, not a QA issue. Before TDD is available, the "Orthodox" development process requires a design document: a high-level design describes a module "what to do", and a detailed design describes a module "how to do these things ". Software engineering courses are clear, onlySource codeThe software cannot be regarded as software because it is not understandable or maintained; SourceCodeAdd a document.ProgramComplete delivery of their work. Before doing anything, you must first know exactly what you want to do (and do not do anything); otherwise, it is crack, not a professional software development.

But such documents have several fatal defects. First, natural language descriptions are prone to ambiguity. Second, they cannot be verified automatically. Third, documents and programs cannot be synchronized. Test-driven development is designed to solve these problems. The test you wrote before writing a piece of code is not to ensure that the Code does not go wrong, butDescribe what you want to do. When you have this test, continuous integration always ensures that your code is exactly what you want to do. Test-driven development is a design method that clearly describes your design and ensures that the design and implementation are consistent.

you can find the answer to several typical questions clearly. Should unit testing be a white box? Yes. Because you are describing how to implement this module , rather than verifying its input and output correctness. Do you want to test each module in a real transaction or concurrent environment? No. Because you only describe the implementation of the current module, the correctness in the real environment is ensured by integrated testing and QA. Why should changes in the internal implementation of the module cause both test changes? Because of your ideas and design changes, you should have a document to describe this matter.

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.