当前位置: 首页 > 知识库问答 >
问题:

'[TestNG]在jar文件中找不到TestNG.xml,在AWS设备场上运行测试时运行所有类的错误

昌山
2023-03-14

我试图在AWS设备场上运行一个测试套件,它是一个Maven项目,我在设备场解析结果文档上得到以下错误:[TestNG]无法在jar文件中找到TestNG.xml,运行所有类。当从Maven为AWS设备场创建zip时,我得到以下警告:[WARNING]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>

共有1个答案

夏侯朝斑
2023-03-14

您需要将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/

 类似资料:
  • 我想在aws-device场中运行一个TestNG xml套件文件。经过调查,我得出结论,aws-device场执行TestNG测试的方式是以随机顺序运行所有用TestNG注释(在上传到设备场的zip文件项目中)注释的测试。这在我的项目中并不适用,因为所有的测试都使用在我的xml套件文件中声明的参数,而且套件文件还声明了测试应该运行的顺序。因此,我无法运行任何测试,因为第一次测试尝试使用在test

  • 我已经使用Appium和Java以及TestNG为Android应用程序编写了一些测试。我的测试在模拟器上本地运行良好,但当我将它们上传到设备场时,我的测试总是失败。我已经尽可能地简化了我的测试,但它仍然不起作用。目前,我尝试运行的测试会在打开应用程序时出现的提示中找到并单击“允许权限”按钮。代码: 观看Device Farm提供的视频,我可以看到它打开并立即关闭我的应用程序。它甚至没有像应该的那

  • 我的项目是一个多模块分级项目,使用Scala。 测试类位于src/Test/scala/xxx/xxxx/xxx/xxxx/xxxxx/xxxxx下,每次尝试从IDE运行时,都会得到相同的错误: 测试类不是什么花哨的,简单的jUnit测试:

  • 在eclipse IDE中,我使用Maven项目创建了一个基本的cucumber框架。 我已经添加了pom.xml.for dependencies下面添加的TestNG插件中所需的所有依赖项。 但是“TestNG套件”选项没有出现在首选项中,所以通过帮助->Install New Software安装TestNG。 testng.xml文件 但它的投掷低于错误

  • 我试图使用XML和TestNG运行一个测试套件,但是我总是同时使用Eclipse和命令行得到相同的消息: 该文件已正确读取,但测试似乎没有运行。 以下是我的testng.xml的内容: 这是我的目录结构在Eclipse中的样子: 此外,这也是我试图通过命令行运行测试套件的方式: 我尝试过通过eclipse清理项目,但似乎没有帮助。我也试过跑步: < code>mvn clean,但它也没有完成工作

  • 我正在评估运行移动web测试的AWS设备场。以下是我预期的步骤: 创建样本测试(Java) 打包为zip文件 通过AWS设备场控制台,仅上传测试zip 手动选择配置和其他东西 手动执行测试并评估结果 我需要帮助的事情是: a)如果测试需要一些更改,我是否需要在每次运行中完成JAR包的创建?我可以从我的IDE运行测试,如果一切正常,然后只打包并上传到AWS设备场? b) 我注意到他们有API来模拟步