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

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.

主站蜘蛛池模板: 德令哈市| 鄂尔多斯市| 淳安县| 安达市| 沧州市| 千阳县| 务川| 通江县| 百色市| 绩溪县| 美姑县| 长岛县| 永年县| 苍溪县| 绍兴市| 中超| 沈丘县| 保定市| 广饶县| 绵竹市| 敖汉旗| 郁南县| 盈江县| 高淳县| 桓台县| 北海市| 筠连县| 军事| 侯马市| 长顺县| 甘谷县| 宁晋县| 塘沽区| 巴彦淖尔市| 通江县| 韶山市| 泸溪县| 东兴市| 巨野县| 枣阳市| 金堂县|