必要なライブラリがすべて利用できるよう、ビルド システムの設定を手動で変更できます。次のセクションでは、単体テスト アシスタント (UTA) が必要とする可能性のあるすべてのライブラリをリストします。構成する必要がある依存関係のセットは、テスト フレームワークに依存し、プロジェクトによって異なる場合があります。

Maven で依存先ライブラリを追加する

<dependencies> セクションを更新して pom.xml ファイルを変更します。

(info) マルチモジュール プロジェクトでは、<dependencyManagement> セクションで依存関係情報を一元化する必要がある場合があります。

JUnit 5 または JUnit 5 と 4 の両方を使用している場合:

<!-- JUnit 5 --> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>5.5.2</version> <scope>test</scope> </dependency> <!-- JUnit 5 runner for JUnit 4--> <dependency> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> <version>5.5.2</version> <scope>test</scope> </dependency> <!-- Mockito --> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <version>3.1.0</version> <scope>test</scope> </dependency> <!-- Add if you create Spring integration tests --> <dependency> 	<groupId>org.springframework</groupId> 	<artifactId>spring-test</artifactId> 	<version>5.2.5.RELEASE</version> 	<scope>test</scope> </dependency>

JUnit 4 だけを使用している場合:

<!-- JUnit 4 --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13</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> <!-- PowerMock for JUnit 4 --> <dependency> <groupId>org.powermock</groupId> <artifactId>powermock-module-junit4</artifactId> <version>2.0.4</version> <scope>test</scope> </dependency> <dependency> <groupId>org.powermock</groupId> <artifactId>powermock-api-mockito2</artifactId> <version>2.0.4</version> <scope>test</scope> </dependency> <!-- Mockito --> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <version>3.1.0</version> <scope>test</scope> </dependency> <!-- Add if you create Spring integration tests --> <dependency> 	<groupId>org.springframework</groupId> 	<artifactId>spring-test</artifactId> 	<version>5.2.5.RELEASE</version> 	<scope>test</scope> </dependency>

Gradle で依存先ライブラリを追加する

次のセクションを変更して build.gradle ファイルを更新します。次のエントリは、必要なライブラリをすべてインクルードします。

JUnit 5 または JUnit 5 と 4 の両方を使用している場合:

test { useJUnitPlatform() } dependencies { // JUnit 5 testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.2' testImplementation 'org.junit.jupiter:junit-jupiter-params:5.5.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.2' // JUnit 5 runner for JUnit 4 testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.5.2' // Mockito testImplementation 'org.mockito:mockito-core:3.1.0' //Add if you create Spring integration tests testImplementation 'org.springframework:spring-test:5.2.5.RELEASE' }


JUnit 4 だけを使用している場合:

dependencies { // JUnit 4 testImplementation 'junit:junit:4.13' // JUnitParams for JUnit4 testImplementation 'pl.pragmatists:JUnitParams:1.1.1' // Powermock for JUnit 4 testImplementation 'org.powermock:powermock-module-junit4:2.0.4' testImplementation 'org.powermock:powermock-api-mockito2:2.0.4' // Mockito testImplementation 'org.mockito:mockito-core:3.1.0' //Add if you create Spring integration tests testImplementation 'org.springframework:spring-test:5.2.5.RELEASE' }

Ant で依存先ライブラリを追加する

Ant の場合、必要なすべての JAR ファイルを個別のディレクトリに追加する必要があります。  build.xml にディレクトリを手動でインクルードする必要があります。

<classpath> <!-- filesets can be used in classpath and bootpath --> 	<fileset dir="C:/directory_name/lib"> 				<include name="**/*.jar"/> </fileset> </classpath>

以下のライブラリが必要です。

  • apiguardian-api-1.1.0.jar
  • byte-buddy-1.10.3.jar
  • byte-buddy-agent-1.10.3.jar
  • hamcrest-2.2.jar
  • javassist-3.26.0-GA.jar
  • junit-4.13.jar
  • junit-jupiter-api-5.5.2.jar
  • junit-jupiter-engine-5.5.2.jar
  • junit-jupiter-migrationsupport-5.5.2.jar
  • junit-jupiter-params-5.5.2.jar
  • JUnitParams-1.1.1.jar
  • junit-platform-commons-1.5.2.jar
  • junit-platform-engine-1.5.2.jar
  • junit-platform-launcher-1.5.2.jar
  • junit-platform-runner-1.5.2.jar
  • junit-platform-suite-api-1.5.2.jar
  • junit-vintage-engine-5.5.2.jar
  • mockito-core-3.1.0.jar
  • mockito-junit-jupiter-3.1.0.jar
  • objenesis-3.1.jar
  • opentest4j-1.2.0.jar
  • powermock-api-mockito2-2.0.4.jar
  • powermock-api-support-2.0.4.jar
  • powermock-core-2.0.4.jar
  • powermock-module-junit4-2.0.4.jar
  • powermock-module-junit4-common-2.0.4.jar
  • powermock-reflect-2.0.4.jar

ライブラリはオンラインまたは [INSTALL_DIR]/examples/demo/lib にあります。

  • No labels