必要な依存先ライブラリがすべて利用できるよう、ビルド システムの設定を手動で変更できます。

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

pom.xml ファイルを編集し、<dependencyManagement><dependencies> および <repositories> セクションを変更します。次のエントリには必要なすべてのライブラリが含まれています。次のエントリは、必要なライブラリをすべてインクルードします。

<dependencyManagement>
      <dependencies>
          <dependency>
              <groupId>org.mockito</groupId>
              <artifactId>mockito-core</artifactId>
              <version>2.23.0</version>
          </dependency>
          <dependency>
              <groupId>net.bytebuddy</groupId>
              <artifactId>byte-buddy</artifactId>
              <version>1.9.3</version>
          </dependency>
          <dependency>
              <groupId>net.bytebuddy</groupId>
              <artifactId>byte-buddy-agent</artifactId>
              <version>1.9.3</version>
          </dependency>
      </dependencies>
</dependencyManagement>

      <dependencies>
          <dependency>
              <groupId>junit</groupId>
              <artifactId>junit</artifactId>
              <version>4.12</version>
              <scope>test</scope>
          </dependency>
          <dependency>
              <groupId>pl.pragmatists</groupId>
              <artifactId>JUnitParams</artifactId>
              <version>1.1.1</version>
              <scope>test</scope>
          </dependency>
          <dependency>
              <groupId>org.powermock</groupId>
              <artifactId>powermock-module-junit4</artifactId>
              <version>2.0.2</version>
              <scope>test</scope>
          </dependency>
          <dependency>
              <groupId>org.powermock</groupId>
              <artifactId>powermock-api-mockito2</artifactId>
              <version>2.0.2</version>
              <scope>test</scope>
          </dependency>
      </dependencies>

      <repositories>
          <repository>
              <id>mockito</id>
              <name>mockito</name>
              <url>https://dl.bintray.com/mockito/maven/</url>
          </repository>
          <repository>
              <id>powermock</id>
              <name>powermock</name>
              <url>https://dl.bintray.com/powermock/maven/</url>
          </repository>
      </repositories>

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

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

repositories {
    maven {
        url  "https://dl.bintray.com/mockito/maven/"
    }
    maven {
        url "https://dl.bintray.com/powermock/maven/"
    }
}

dependencies {
    testCompile 'junit:junit:4.12'
    testCompile 'pl.pragmatists:JUnitParams:1.1.1'
    testCompile 'org.mockito:mockito-core:2.23.0'
    testCompile 'org.powermock:powermock-module-junit4:2.0.2'
    testCompile 'org.powermock:powermock-api-mockito2:2.0.2'
}

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>

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

  • junit-4.12.jar
  • JUnitParams-1.1.1.jar
  • hamcrest-core-1.3.jar
  • javassist-3.24.0-GA.jar
  • byte-buddy-1.9.3.jar
  • byte-buddy-agent-1.9.3.jar
  • objenesis-2.6.jar
  • mockito-core-2.23.0.jar
  • powermock-mockito2-2.0.2-full.jar

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

  • No labels