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

Adding JUnit as dependency

Recall that we have a multi-module project, and the dependency versions are maintained in the parent POM under the dependencyManagement tag.

<dependencyManagement> 
<dependencies>
...
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

The scope of the dependency is test, which means that this library is needed only to compile the test code and during the execution of the test. The JUnit library will not make its way to the final released product; there is no need for it. If you find the JUnit library in some deployed production Web Archive (WAR) file, suspect that somebody was not properly managing the scopes of the libraries.

Maven supports the compilation and the execution of JUnit tests in the lifecycle of the project. If we want to execute the tests, only we can issue the mvn test command. The IDEs also support the execution of the unit tests. Usually, the same menu item that can be used to execute a class that has a public static main method can be used. If the class is a unit test utilizing JUnit, the IDE will recognize it and execute the tests and usually give a graphical feedback on what test was executing fine and which ones failed, and how.

主站蜘蛛池模板: 九寨沟县| 柏乡县| 隆尧县| 监利县| 康马县| 新兴县| 上饶县| 丽水市| 靖州| 剑阁县| 长治县| 株洲市| 静海县| 利辛县| 思茅市| 平泉县| 洛浦县| 安义县| 白玉县| 科技| 平阳县| 云安县| 昌宁县| 甘孜| 松原市| 吉安市| 郁南县| 平阴县| 安远县| 屯昌县| 武隆县| 吉木萨尔县| 宜城市| 沂南县| 金寨县| 屏边| 吴旗县| 乌拉特前旗| 浦城县| 崇明县| 苏尼特右旗|