What is test-driven development

Source: Internet
Author: User

1: The traditional coding method

2: test-driven development

It features the following

2.1: Write a failed unit test to prove that there is a flaw in the product code to fix the flaw

When we want to implement a user's Add method User.add, we will write a test method to verify the User.add. Of course the initial test will certainly fail, because we don't have

Write User.add encoding so that after the run fails we will implement this code until it is passed

2.2: Write code that meets the test expectations, which is tested by 2.3: Refactoring code

For the first time, our code is definitely designed to be readable, and the specification is not very efficient, so we will refactor our codes until we write good coding.

3: Advantages of Unit Testing: 3. 1: Quickly find bugs in your project

Because in the code of our own manual testing is not universal, analogy to verify null, not to add judgment, a lot of code is unrestrained, so in other people after testing everywhere is a bug, constantly repeated changes are not finished, began overtime overtime

Cause the morale of the people is low. And so on after the product on-line every day to deal with a variety of bugs very painful. So by adding unit tests early, this would reduce most of the hassle.

3.2: Code refactoring

Refactoring we are not unfamiliar, why refactor, because no refactoring is impossible to see, or naming rules, or methods too long, or inefficient and so on, but if we do not participate in unit testing, you such a refactoring, but also manually point to test

After the project is submitted, there are new bugs, and you might be working with people complaining, refactoring every day, and now there's a problem. The team will be complaining, the final result of everyone will not refactor the code, know that it is not right. So unit testing is very heavy in refactoring.

's Status

The advantage is personal opinion. Familiar with TDD can give advice

To be the art of reference Unit testing.

What is test-driven development

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.