- Java 9 Programming By Example
- Peter Verhas
- 203字
- 2021-07-02 23:37:38
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.
- VMware View Security Essentials
- jQuery EasyUI網站開發實戰
- Python數據分析(第2版)
- RISC-V體系結構編程與實踐(第2版)
- FPGA Verilog開發實戰指南:基于Intel Cyclone IV(進階篇)
- Instant Lucene.NET
- 零基礎學C語言程序設計
- 現代C:概念剖析和編程實踐
- MyBatis 3源碼深度解析
- Learning Jakarta Struts 1.2: a concise and practical tutorial
- 程序員必會的40種算法
- 深入理解Java虛擬機:JVM高級特性與最佳實踐
- Sitecore Cookbook for Developers
- 一步一步學Spring Boot:微服務項目實戰(第2版)
- 樹莓派開發從零開始學:超好玩的智能小硬件制作書