官术网_书友最值得收藏!

Creating unit tests

When we write code, we should test it. No code has ever gone into production before at least doing some test runs. There are different levels of tests having different aims, technologies, industry practices, and names.

Unit tests, as the name suggests, test a unit of code. Integration tests test how the units integrate together. Smoke tests test a limited set of the features just to see that the code is not totally broken. There are other tests, until the final test, which is the proof of the work: user acceptance test. Proof of the pudding is eating it. A code is good if the user accepts it.

Many times, I tell juniors that the name user acceptance test is a bit misleading, because it is not the user who accepts the result of a project, but the customer. By definition, the customer is the person who pays the bill. Professional development is paid; otherwise, it is not professional. The terminology is, however, user acceptance test. It just happens that customers accept the project only if the users can use the program.

When we develop in Java, unit test is testing standalone classes. In other words, in Java development, a unit is a class when we talk about unit tests. To furnish unit tests, we usually use the JUnit library. There are other libraries, such as TestNG, but JUnit is the most widely used, so we will use JUnit. To use it as a library, first, we will have to add it to the Maven POM as a dependency.

主站蜘蛛池模板: 宁强县| 华宁县| 右玉县| 建阳市| 普定县| 安陆市| 徐水县| 白水县| 隆尧县| 桂东县| 广德县| 新化县| 南木林县| 丰城市| 马边| 金门县| 阳春市| 阿城市| 十堰市| 郸城县| 凯里市| 连南| 金华市| 沅陵县| 昭通市| 图木舒克市| 南靖县| 鱼台县| 柞水县| 泸水县| 马关县| 大悟县| 资兴市| 恩施市| 临城县| 奇台县| 确山县| 枣强县| 财经| 河池市| 漠河县|