AWS Device Farm:APPIUM_JAVA_JUNIT_TEST_PACKAGE_CLASS_FILE_MISSING_IN_TESTS_JAR

AWS Device Farm: APPIUM_JAVA_JUNIT_TEST_PACKAGE_CLASS_FILE_MISSING_IN_TESTS_JAR

我正在尝试将 Appium Java JUnit 测试上传到 AWS Device Farm。 我这样配置 pom.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.acme</groupId>
   <artifactId>acme-android-appium</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>jar</packaging>
       <repositories>
            <repository>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
            </releases>
            <id>Experitest.repo1</id>
            <name>YourName</name>
            <url>https://cloud.experitest.com/repo/</url>
            <layout>default</layout>
        </repository>
    </repositories>
   <build>
      <sourceDirectory>src</sourceDirectory>
      <plugins>
         <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
               <source>1.8</source>
               <target>1.8</target>
            </configuration>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <classesDirectory>dummy</classesDirectory>
            </configuration>
            <version>2.6</version>
            <executions>
               <execution>
                  <goals>
                     <goal>test-jar</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.10</version>
            <executions>
               <execution>
                  <id>copy-dependencies</id>
                  <phase>package</phase>
                  <goals>
                     <goal>copy-dependencies</goal>
                  </goals>
                  <configuration>
                     <outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.5.4</version>
            <executions>
               <execution>
                  <phase>package</phase>
                  <goals>
                     <goal>single</goal>
                  </goals>
                  <configuration>
                     <finalName>zip-with-dependencies</finalName>
                     <appendAssemblyId>false</appendAssemblyId>
                     <descriptors>
                        <descriptor>src/main/assembly/zip.xml</descriptor>
                     </descriptors>
                  </configuration>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>
   <dependencies>
      <dependency>
         <groupId>com.amazonaws</groupId>
         <artifactId>aws-lambda-java-core</artifactId>
         <version>1.1.0</version>
      </dependency>
      <!-- extentreports -->
      <dependency>
         <groupId>com.relevantcodes</groupId>
         <artifactId>extentreports</artifactId>
         <version>2.41.2</version>
      </dependency>
      <dependency>
         <groupId>com.experitest</groupId>
         <artifactId>appium</artifactId>
         <version>4.1.2</version>
      </dependency>
   </dependencies>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
</project>

当我尝试通过 Maven 编译我的代码时(通过 CMD 使用此命令:mvn clean package -DskipTests=true)我得到了一些信息行,包括以下信息:

[WARNING] /C:/Users/Adam Peretz/workspace/Sweetch/src/Utilites/CommonOps.java: Some input files use unchecked or unsafe operations.

[WARNING] /C:/Users/Adam Peretz/workspace/Sweetch/src/Utilites/CommonOps.java: Recompile with -Xlint:unchecked for details.

[WARNING] JAR will be empty - no content was marked for inclusion!

[INFO] BUILD SUCCESS

然后,我将“zip-with-dependencies.zip”文件上传到 AWS Device Farm 并收到此错误:

There was a problem processing your file. We could not find a class file within the tests JAR file. Please unzip your test package and then unjar the tests JAR file, verify that at least one class file is within the JAR file, and try again. For more information about this issue, please see the documentation.

我该怎么办?我真的不知道该怎么办,我什么都试过了。

您将 Java 文件放在哪里?该警告与默认情况下在 maven 中创建的 jar 文件有关,而不是 *-test.jar

Device Farm使用*-test.jar文件,报错信息提示该文件为空。 ./src/test/java下的测试Java文件是吗?如果不是,他们将需要否则 Maven 不会将那些 class 文件打包到 *-test.jar 中。

这里有一个例子可以比较。

https://github.com/aws-samples/aws-device-farm-appium-tests-for-sample-app

希望对您有所帮助

詹姆斯