- 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.
- Java程序設計與開發
- JavaScript修煉之道
- Effective C#:改善C#代碼的50個有效方法(原書第3版)
- Hands-On Data Structures and Algorithms with JavaScript
- Python數據挖掘與機器學習實戰
- C語言程序設計同步訓練與上機指導(第三版)
- 動手學數據結構與算法
- 匯編語言編程基礎:基于LoongArch
- 編程改變生活:用Python提升你的能力(進階篇·微課視頻版)
- 從Power BI到Analysis Services:企業級數據分析實戰
- Python趣味編程與精彩實例
- 深度學習程序設計實戰
- LabVIEW數據采集
- 微信公眾平臺開發最佳實踐
- Instant OpenCV for iOS