The practical way of automated unit testing

Source: Internet
Author: User

Automated unit testing is nothing new, it should be the team's perseverance, there may be a lot of teams who know how to do it, but it's not good enough, and a lot of teams don't know how to do it, and even some of the old systems don't have the guts to refactor, and they stick to the way the main method calls in Java, In the long wait to build results.

This paper focuses on the practice of how to do automated unit testing based on Java projects.

1 whether it is worthwhile

For the purpose of unit testing, refer to StackOverflow's article in detail:

Http://stackoverflow.com/questions/67299/is-unit-testing-worth-the-effort,

Martin Fowler, in his blog (http://martinfowler.com/bliki/TestPyramid.html), explained

Testpyramid, as shown in the following illustration:

Figure -1-1-testpyramid

Unit is the cornerstone of the entire pyramid (in the construction industry, the cornerstone of building stone), if the cornerstone of instability, service and UI what is the construction of the meaning of it? Only the cornerstone is rock solid, the superstructure is strong enough.

I wanted to illustrate the example of a Swiss timepiece, but my colleague said that the car example was better. A car is made up of many accessories, which would you choose if you have the following two options?

All unit parts have not been tested, in the 4S shop, sales staff tell you: just assembled, has been open a day, can run up, you can try;

All unit parts in the production process has been strictly tested at 4S Point, the sales staff told you, has passed the national certification, factory qualified, have quality assurance, you can try;

The answer goes without saying.

Implement unit tests, does not mean that your productivity can increase rapidly, but sometimes hinder the instantaneous productivity (the traditional development of a function, seemingly even the completion of the action, to increase unit testing does not seem to be a waste of time), but it is the most direct to improve product quality, so as to enhance the image of the market, Indirect will increase productivity.

Do products, in the end is to quantity, or quality? This should be left to the bosses to answer, see whether the enterprise needs long-term foothold.

2 Key Parts

Automated unit testing has four key components to unify, as shown in the figure:

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.