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: