前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Appium系列|Appium测试框架完善(四)

Appium系列|Appium测试框架完善(四)

作者头像
测试邦
发布2019-07-24 09:53:40
4630
发布2019-07-24 09:53:40
举报
文章被收录于专栏:测试邦测试邦测试邦

测试报告生成

在IDE里执行测试脚本执行完后可以将测试结果导出成JUnit或者html格式的都可以,但后续我们做持续集成的时候期望一步到位执行可以生成这两种格式的报告,那怎么让执行后直接生成呢?我们现在来具体看下。

我们会借助ReportNG插件来达到上面的目的,ReportNG是一种TestNG里用来进行HTML/XML格式展示的插件。

那因为我们是通过Maven来进行依赖管理的,ReportNG又会依赖其他的库,我们在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.appium</groupId>
    <artifactId>appium</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.9.10</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>5.0.3</version>
        </dependency>

        <dependency>
            <groupId>org.uncommons</groupId>
            <artifactId>reportng</artifactId>
            <version>1.1.4</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.testng</groupId>
                    <artifactId>testng</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>velocity</groupId>
            <artifactId>velocity</artifactId>
            <version>1.4</version>
        </dependency>

        <dependency>
            <groupId>velocity</groupId>
            <artifactId>velocity-dep</artifactId>
            <version>1.4</version>
        </dependency>

        <!--add these two to avoid errors-->
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>4.1.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>21.0</version>
        </dependency>


    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <properties>
                        <property>
                            <name>usedefaultlisteners</name>
                            <value>false</value>
                        </property>
                    </properties>
                    <!-- 后续可以更改这个suite名词来执行指定的suite-->
                    <suiteXmlFiles>
                        <suiteXmlFile>suite.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!--define enconding -->
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
    </properties>

</project>

依赖配置完后还需要去suite.xml里添加HTML和JUnit报告的插件如下:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Suite1" verbose="1" >
    <listeners>
        <listener class-name="appium.listeners.TestListener"/>
        <listener class-name="appium.listeners.RerunListener"/>
        <listener class-name="org.uncommons.reportng.HTMLReporter"/>
        <listener class-name="org.uncommons.reportng.JUnitXMLReporter"/>
    </listeners>
    <test name="Regression1">
        <classes>
            <class name="appium.testcases.login.LoginPermissionCheck"/>
            <class name="appium.testcases.versioncheck.VersionCheck"/>
        </classes>
    </test>
</suite>

这时候鼠标右键执行下suite.xml看下执行完会不会产生xml和html格式的报告。

执行完可以到在测试工程根目录下产生了个test-output的文件夹,文件夹下有xml和html格式的报告,如下图所示:

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-07-16,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 测试邦 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 测试报告生成
相关产品与服务
持续集成
CODING 持续集成(CODING Continuous Integration,CODING-CI)全面兼容 Jenkins 的持续集成服务,支持 Java、Python、NodeJS 等所有主流语言,并且支持 Docker 镜像的构建。图形化编排,高配集群多 Job 并行构建全面提速您的构建任务。支持主流的 Git 代码仓库,包括 CODING 代码托管、GitHub、GitLab 等。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档