欢迎光临散文网 会员登陆 & 注册

Selenium3+Pytest+Allure 全流程实战自动化测试

2023-07-14 13:54 作者:bili_48219728313  | 我要投稿

Selenium3+Pytest+Allure 全流程实战自动化测试

参考资料:https://pan.baidu.com/s/1lKtXih4fZsTe__BUA3wwnw 提取码: x8mw



Allure介绍


Allure是一款测试报告框架,不仅报告美观,而且方便CI集成。

allure是一款开源的,专门用来展示测试结果的一个工具,allure可以与很多的测试框架做集成,比如:java的Junit、TestNG;python的pytest等。

allure会将测试用例的执行数据保存到xml或者json文件中去,再利用allure的命令行将文件转换成HTML形式呈现出来。


1. 搭建Web测试环境1.1. 安装JDK并配置环境变量

1) 在Java官方网站上下载相应系统的jdk文件安装,如win7 64位系统下安装 jdk-6u45-windows-x64,全部选择默认的安装路径即可安装完成;

2) 新建JAVA_HOME环境变量,变量值是自己安装JDK的路径,我的是D:Javajdk1.87.0;

3) 新建环境变量classpath

变量值是:JAVA_HOME /lib/dt.jar; JAVA_HOME /lib/tools.jar;

4) 找到PATH环境变量,

追加如下目录JAVA_HOME /bin; JAVA_HOME /jre/bin;

5) 验证安装是否成功。

打开 cmd 命令行窗口

在命令行窗口中输入 java -version,显示如下内容表示安装成功


添加依赖

这里匹配的是.Test结尾的java文件**(记得放在test目录下,切记!!)**

<?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.hogwarts</groupId>

    <artifactId>AllureDemo2</artifactId>

    <version>1.0-SNAPSHOT</version>

    <dependencies>

        <dependency>

            <groupId>org.junit.jupiter</groupId>

            <artifactId>junit-jupiter</artifactId>

            <version>RELEASE</version>

            <scope>test</scope>

        </dependency>

        <dependency>

            <groupId>org.hamcrest</groupId>

            <artifactId>hamcrest</artifactId>

            <version>2.2</version>

            <scope>test</scope>

        </dependency>

        <dependency>

            <groupId>io.qameta.allure</groupId>

            <artifactId>allure-junit5</artifactId>

            <version>2.13.6</version>

            <scope>test</scope>

        </dependency>

        <dependency>

            <groupId>org.junit.platform</groupId>

            <artifactId>junit-platform-console-standalone</artifactId>

            <version>1.7.0</version>

        </dependency>

        <dependency>

            <groupId>org.hamcrest</groupId>

            <artifactId>hamcrest</artifactId>

            <version>2.1</version>

            <scope>compile</scope>

        </dependency>

    </dependencies>

     <properties>

        <maven.compiler.source>8</maven.compiler.source>

        <maven.compiler.target>8</maven.compiler.target>

        <aspectj.version>1.8.10</aspectj.version>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    </properties>

    <build>

        <plugins>

            <plugin>

                <artifactId>maven-surefire-plugin</artifactId>

                <version>3.0.0-M5</version>

                <configuration>

                    <includes>

                        <include>**/*Test.java</include>

                    </includes>

                </configuration>

            </plugin>

        </plugins>

    </build>

</project>


Selenium3+Pytest+Allure 全流程实战自动化测试的评论 (共 条)

分享到微博请遵守国家法律