课堂PPT
PPT地址
接口
- 有输入参数和输出内容的一套有逻辑处理单元
企业微信
https://developer.work.weixin.qq.com/document/path/90664
pom
<properties>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<!-- 使用 Java 11 语言特性 ( -source 11 ) 并且还希望编译后的类与 JVM 11 ( -target 11 )兼容,
可以添加以下两个属性,它们是默认属性插件参数的名称 -->
<java.version>11</java.version>
<!-- 对应junit Jupiter的版本号;放在这里就不需要在每个依赖里面写版本号,导致对应版本号会冲突 -->
<junit.jupiter.version>5.8.2</junit.jupiter.version>
<!-- maven-plugins -->
<maven.compiler.version>3.8.1</maven.compiler.version>
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
<!-- 断言 -->
<hamcrest.version>2.2</hamcrest.version>
<!-- log日志 -->
<slf4j.version>2.0.0-alpha7</slf4j.version>
<logback.version>1.3.0-alpha16</logback.version>
<!-- allure报告 -->
<allure.version>2.18.1</allure.version>
<aspectj.version>1.9.9.1</aspectj.version>
<allure-maven.version>2.10.0</allure-maven.version>
<allure.cmd.download.url>
https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline
</allure.cmd.download.url>
<!-- faker -->
<javafaker.version>1.0.2</javafaker.version>
<!-- selenium -->
<selenium.version>4.3.0</selenium.version>
<!-- appium -->
<appium.version>8.1.1</appium.version>
<!-- rest-assured -->
<rest-assured.version>5.1.1</rest-assured.version>
<!-- fasterjson -->
<jackson.version>2.13.1</jackson.version>
<!-- apache-commonio -->
<commonio.version>2.11.0</commonio.version>
</properties>
<!-- 物料清单 (BOM)-->
<dependencyManagement>
<dependencies>
<!--当使用 Gradle 或 Maven 引用多个 JUnit 工件时,此物料清单 POM 可用于简化依赖项管理。不再需要在添加依赖时设置版本-->
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit.jupiter.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!--junit5-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<!--对应添加的依赖的作用范围-->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<!--hamcrest断言-->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<!--faster json解析yaml文件 -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>${jackson.version}</version>
<scope>compile</scope>
</dependency>
<!-- csv文件解析-->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-csv</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- log日志 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<!-- common io-->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commonio.version}</version>
</dependency>
<!-- allure-->
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-junit5</artifactId>
<version>${allure.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
<scope>runtime</scope>
</dependency>
<!-- 随机测试数据生成库 -->
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>${javafaker.version}</version>
</dependency>
<!-- selenium-->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
<scope>compile</scope>
</dependency>
<!-- appium -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>${appium.version}</version>
<scope>compile</scope>
</dependency>
<!-- rest-assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${rest-assured.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>${rest-assured.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<includes>
<include>**/*Test</include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<parameters>true</parameters>
<!-- 设置jre版本为 11 -->
<source>${java.version}</source>
<target>${java.version}</target>
<!-- 设置编码为 UTF-8 -->
<encoding>${maven.compiler.encoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>${allure-maven.version}</version>
<configuration>
<reportVersion>${allure.version}</reportVersion>
<allureDownloadUrl>${allure.cmd.download.url}/${allure.version}/allure-commandline-${allure.version}.zip</allureDownloadUrl>
</configuration>
</plugin>
</plugins>
</build>
json Schema
json viewer
gpath验证
https://onecompiler.com/groovy/3xxb42jsb
import groovy.json.JsonSlurper
def jsonSlurper = new JsonSlurper()
def one = jsonSlurper.parseText('{"errcode":0,"errmsg":"ok","department":[{"id":1,"name":"产研部","parentid":0,"order":100000000,"department_leader":[]},{"id":2,"name":"质量控制部","parentid":1,"order":100000000,"department_leader":[]},{"id":3,"name":"产品部","parentid":1,"order":99999000,"department_leader":[]},{"id":4,"name":"后端研发部","parentid":1,"order":99998000,"department_leader":[]},{"id":5,"name":"前端部门","parentid":1,"order":99997000,"department_leader":[]},{"id":6,"name":"测试一组1","parentid":2,"order":100000000,"department_leader":[]},{"id":7,"name":"测试二组2","parentid":2,"order":99999000,"department_leader":[]},{"id":8,"name":"刘越彬1648352111146","parentid":1,"order":475,"department_leader":[]},{"id":9,"name":"孙雨泽1648352112153","parentid":1,"order":771,"department_leader":[]},{"id":10,"name":"徐煜城1648352112988","parentid":1,"order":321,"department_leader":[]},{"id":11,"name":"戴鹭洋1648352113646","parentid":1,"order":901,"department_leader":[]},{"id":12,"name":"熊明1648352114249","parentid":1,"order":547,"department_leader":[]},{"id":13,"name":"田建辉1648352114899","parentid":1,"order":75,"department_leader":[]},{"id":14,"name":"梁健雄1648352115509","parentid":1,"order":521,"department_leader":[]}]}')
println(one)
def id = one.department.findAll{ it.order < 1000}.id
println(id)
作业
https://developer.work.weixin.qq.com/document/path/95350
- 部门相关用例补全
- 查找部门用json schema模版断言
- 查找部门的时候找出来id < 100的所有部门的 order 为list
- 命令行运行并生成allure报告