必要なライブラリがすべて利用できるよう、ビルド システムの設定を手動で変更できます。次のセクションでは、単体テスト アシスタント (UTA) が必要とする可能性のあるすべてのライブラリをリストします。構成する必要がある依存関係のセットは、テスト フレームワークに依存し、プロジェクトによって異なる場合があります。
<dependencies> セクションを更新して pom.xml ファイルを変更します。
マルチモジュール プロジェクトでは、
<dependencyManagement> セクションで依存関係情報を一元化する必要がある場合があります。
JUnit 5 または JUnit 5 と 4 の両方を使用している場合:
<!-- JUnit 5 -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.12.1</version>
<scope>test</scope>
</dependency>
<!-- JUnit 5 runner for JUnit 4-->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.12.1</version>
<scope>test</scope>
</dependency>
<!-- Mockito 5 for projects with Java 11 or newer -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.16.0</version>
<scope>test</scope>
</dependency>
<!-- Mockito 4 for projects with Java 8, 9, 10 -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
<!-- Add if you create Spring integration tests -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.3.39.RELEASE</version>
<scope>test</scope>
</dependency> |
JUnit 4 だけを使用している場合:
<!-- JUnit 4 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<!-- JUnitParams for JUnit 4 -->
<dependency>
<groupId>pl.pragmatists</groupId>
<artifactId>JUnitParams</artifactId>
<version>1.1.1</version>
<scope>test</scope>
</dependency>
<!-- Mockito 5 for projects with Java 11 or newer -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.16.0</version>
<scope>test</scope>
</dependency>
<!-- Mockito 4 for projects with Java 8, 9, 10 -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
<!-- Add if you create Spring integration tests -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.3.39.RELEASE</version>
<scope>test</scope>
</dependency> |
次のセクションを変更して build.gradle ファイルを更新します。次のエントリは、必要なライブラリをすべてインクルードします。
JUnit 5 または JUnit 5 と 4 の両方を使用している場合:
test {
useJUnitPlatform()
}
dependencies {
// JUnit 5
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.12.1'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.12.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.12.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.12.1'
// JUnit 5 runner for JUnit 4
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.12.1'
// Mockito 5 for projects with Java 11 or newer
testImplementation 'org.mockito:mockito-core:5.16.0'
// Mockito 4 for projects with Java 8, 9, 10
testImplementation 'org.mockito:mockito-inline:4.11.0'
// Add if you create Spring integration tests
testImplementation 'org.springframework:spring-test:5.3.39.RELEASE'
} |
JUnit 4 だけを使用している場合:
dependencies {
// JUnit 4
testImplementation 'junit:junit:4.13.2'
// JUnitParams for JUnit4
testImplementation 'pl.pragmatists:JUnitParams:1.1.1'
// Mockito 5 for projects with Java 11 or newer
testImplementation 'org.mockito:mockito-core:5.16.0'
// Mockito 4 for projects with Java 8, 9, 10
testImplementation 'org.mockito:mockito-inline:4.11.0'
// Add if you create Spring integration tests
testImplementation 'org.springframework:spring-test:5.3.39.RELEASE'
} |
Ant の場合、必要なすべての JAR ファイルを個別のディレクトリに追加する必要があります。 build.xml にディレクトリを手動でインクルードする必要があります。
<classpath>
<!-- filesets can be used in classpath and bootpath -->
<fileset dir="C:/directory_name/lib">
<include name="**/*.jar"/>
</fileset>
</classpath> |
以下のライブラリが必要です。
ライブラリはオンラインまたは <INSTALL_DIR>/examples/demo/lib にあります。