您可以手动修改您的构建系统,以确保提供所需的库。以下部分列出了 UTA 可能需要的所有库。需要配置的依赖项取决于您的测试框架,并且可能因项目而异。
在 Maven 中添加依赖项
通过更新 <dependencies>
部分来修改 pom.xml 文件。
多模块项目可能需要将依赖项信息集中在
<dependencyManagement>
部分。
如果使用 JUnit 5 或同时使用 JUnit 5 与 JUnit 4:
<!-- JUnit 5 --> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>5.9.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.9.2</version> <scope>test</scope> </dependency> <!-- Mockito-inline --> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-inline</artifactId> <version>4.4.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.18.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-inline --> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-inline</artifactId> <version>4.4.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.18.RELEASE</version> <scope>test</scope> </dependency>
在 Gradle 中添加依赖项
通过更新以下部分来修改 build.gradle 文件。以下条目包括所有必需的库:
如果使用 JUnit 5 或同时使用 JUnit 5 与 JUnit 4:
test { useJUnitPlatform() } dependencies { // JUnit 5 testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2' testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2' testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.9.2' // JUnit 5 runner for JUnit 4 testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.9.2' // Mockito-inline testImplementation 'org.mockito:mockito-inline:4.4.0' //Add if you create Spring integration tests testImplementation 'org.springframework:spring-test:5.3.18.RELEASE' }
如果只使用 JUnit 4:
dependencies { // JUnit 4 testImplementation 'junit:junit:4.13.2' // JUnitParams for JUnit4 testImplementation 'pl.pragmatists:JUnitParams:1.1.1' // Mockito-inline testImplementation 'org.mockito:mockito-inline:4.4.0' //Add if you create Spring integration tests testImplementation 'org.springframework:spring-test:5.3.18.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.2.jar
- byte-buddy-1.12.8.jar
- byte-buddy-agent-1.12.8.jar
- hamcrest-2.2.jar
- junit-4.13.2.jar
- junit-jupiter-api-5.9.2.jar
- junit-jupiter-engine-5.9.2.jar
- junit-jupiter-migrationsupport-5.9.2.jar
- junit-jupiter-params-5.9.2.jar
- JUnitParams-1.1.1.jar
- junit-platform-commons-1.9.2.jar
- junit-platform-engine-1.9.2.jar
- junit-platform-launcher-1.9.2.jar
- junit-platform-runner-1.9.2.jar
- junit-platform-suite-api-1.9.2.jar
- junit-vintage-engine-5.9.2.jar
- mockito-inline-4.4.0.jar
- mockito-junit-jupiter-4.4.0.jar
- objenesis-3.2.jar
- opentest4j-1.2.0.jar
这些库可在线获取或在 <INSTALL_DIR>
/examples/demo/lib
中获取。