Appium Java JUNIT上传AWS遇问题:未找到*-tests.jar文件求助
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
targetfolder for a jar file ending with-tests.jar. - For Gradle: Check the
build/libsfolder 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 insrc/main/javainstead, the build tool won’t recognize them as test classes and won’t include them in the*-tests.jar.
内容的提问来源于stack exchange,提问作者Nir Kalsi

