You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Appium Java JUNIT上传AWS遇问题:未找到*-tests.jar文件求助

Fixing "We could not find a *-tests.jar file" Error When Uploading Appium Java JUNIT Tests to AWS

I’ve run into this exact issue before and spent quite a bit of time troubleshooting it—here are several actionable solutions that helped me resolve it:

1. Ensure Your Build Tool is Configured to Generate the Tests Jar

By default, build tools like Maven and Gradle don’t automatically package your test classes into a *-tests.jar file. You need to explicitly configure them to do so:

For Maven (pom.xml):

Add the maven-jar-plugin with the test-jar goal to your build configuration:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.3.0</version> <!-- Use the latest stable version -->
            <executions>
                <execution>
                    <goals>
                        <goal>test-jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

After adding this, run mvn clean package—this will generate the tests jar in the target directory, named something like your-project-name-tests.jar.

For Gradle (build.gradle):

Add a custom task to build the tests jar:

task testJar(type: Jar) {
    from sourceSets.test.output
    archiveClassifier = 'tests'
}

artifacts {
    archives testJar
}

Run gradle clean testJar or gradle clean build to generate the jar, which will be located in the build/libs directory.

2. Verify Your Build Command

Don’t just run mvn test or gradle test—these commands only execute tests but don’t package them into a jar. You need to run the package/build commands mentioned above to generate the *-tests.jar file.

3. Check for Compilation Errors in Tests

If your test classes have compilation errors, the build tool will skip generating the tests jar. Check your build logs carefully for any errors related to test classes—fix those first, then re-run the build.

4. Confirm the Jar’s Location and Naming

  • For Maven: Look in the target folder for a jar file ending with -tests.jar.
  • For Gradle: Check the build/libs folder for the same naming pattern.
    Make sure you’re uploading this exact file to AWS—sometimes it’s easy to mix up the main project jar with the tests jar.

5. Validate Your Test Class Structure

Ensure all your JUNIT test classes are placed in the standard test directory:

  • Maven/Gradle: src/test/java
    If your tests are in src/main/java instead, the build tool won’t recognize them as test classes and won’t include them in the *-tests.jar.

内容的提问来源于stack exchange,提问作者Nir Kalsi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:39:40