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

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.

主站蜘蛛池模板: 大方县| 扎兰屯市| 高平市| 新巴尔虎左旗| 霞浦县| 金坛市| 文水县| 乐至县| 无锡市| 德安县| 镇沅| 武城县| 漠河县| 电白县| 大化| 凤城市| 普定县| 邢台市| 孟津县| 晋城| 太仆寺旗| 长宁区| 海丰县| 雅安市| 满城县| 青海省| 共和县| 盐津县| 大悟县| 颍上县| 清水河县| 临江市| 灵丘县| 兴海县| 渝中区| 米易县| 鹤壁市| 兴隆县| 东兰县| 吴川市| 贵溪市|