【问题标题】:'[TestNG] Couldn't find the testng.xml in the jar file, running all the classes' error while running test on AWS Device Farm'[TestNG] 无法在 jar 文件中找到 testng.xml,在 AWS Device Farm 上运行测试时运行所有类的错误
【发布时间】:2018-02-26 19:07:54
【问题描述】:

我正在尝试在 AWS 设备场上运行测试套件,它是一个 Maven 项目,我在设备场解析结果文档中收到以下错误:[TestNG] 无法在 jar 文件中找到 testng.xml ,运行所有的类。 从 Maven 为 AWS 设备场创建 zip 时,我收到以下警告: [警告] org.testng:testng:jar:5.14.3 的 POM 无效,传递依赖项(如果有)将不可用,请启用调试日志以获取更多详细信息。 我有最新版本的 testng 和 surefire 插件似乎没有任何帮助。对此的任何帮助将不胜感激。

我的 pom.xml 如下: http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<groupId>com.pankanis.cameraplus </groupId>
<artifactId>CameraPlusApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>CameraPlusApp</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <suiteXmlFile>./testng.xml</suiteXmlFile>
</properties>

<dependencies>

    <!-- https://mvnrepository.com/artifact/io.appium/java-client -->
    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>4.1.2</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.53.1</version>
    </dependency>
    <dependency>

        <groupId>com.github.genium-framework</groupId>

        <artifactId>Appium-Support</artifactId>

        <version>1.0.5</version>

    </dependency>
    <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>1.4.9</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.5</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.11</version>
    </dependency>
    <dependency>
        <groupId>com.sikulix</groupId>
        <artifactId>sikulixapi</artifactId>
        <version>1.1.0</version>
    </dependency>
    <dependency>
        <groupId>xml-apis</groupId>
        <artifactId>xml-apis</artifactId>
        <version>1.4.01</version>
    </dependency>
    <dependency>
        <groupId>com.relevantcodes</groupId>
        <artifactId>extentreports</artifactId>
        <version>2.41.1</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.9</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <dependency>
        <groupId>org.uncommons</groupId>
        <artifactId>reportng</artifactId>
        <version>1.1.4</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
            <configuration>
                <source>${jdk.version}</source>
                <target>${jdk.version}</target>
            </configuration>

        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20.1</version>
            <configuration>

                <suiteXmlFiles>
                    <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
                </suiteXmlFiles>


            </configuration>

        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <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>

【问题讨论】:

  • 您好 Ronit,我在 Device Farm 团队工作。在 Device Farm 上,您是否收到错误或无法找到 testng.xml 文件的警告?这应该是警告而不是错误。告诉我。
  • 嗨 NikofTime,你是对的,这是一个警告而不是错误,实际错误是/是 '[error] RunTimeINIT: *** terminating: libs to export not found on above classpath: / sikulixlibs/linux/libs64',我找不到出路,所以删除了我的 sikuli 脚本。对此的任何帮助将不胜感激!

标签: maven testng aws-device-farm


【解决方案1】:

您需要将 testng.xml 添加到创建的 -tests.jar 文件的根目录中。为此,请将其放在 src/test/resources 目录中,以利用超级 pom 配置。或者,您可以创建一些 testResources 标记来引用 testng.xml 当前所在的位置。 希望有帮助

刚刚在这里添加了一个拉取请求

https://github.com/awslabs/aws-device-farm-appium-tests-for-sample-app/pull/14

[更新]

现在有一篇关于此的高级支持文章 https://aws.amazon.com/premiumsupport/knowledge-center/xml-file-tests-jar-file-device-farm/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-03
    • 2016-05-13
    • 2020-05-16
    • 2017-12-12
    相关资源
    最近更新 更多