随笔分类 - 测试 / junit5
摘要:查看官网:https://docs.qameta.io/allure/#_junit_5 源码example: https://github.com/allure-examples/allure-examples/tree/master/allure-junit5/src/test/java/io/
阅读全文
摘要:命令格式: allure [option] [command] [command options] allure --help 帮助 allure --version 查看版本信息 allure serve 生成在线版本的测试 allure generate <allure-result中间文件>
阅读全文
摘要:1、安装 Java (推荐 1.8 版本),需要配置环境变量2、安装 Allure (2.13以上版本),需要配置环境变量 【下载地址】 https://repo1.maven.org/maven2/io/qameta/allure/allure-commandline/ mac/linux: 下载
阅读全文
摘要:给用例添加禁用标识,被禁用的用例执行后会添加跳过的状态,可以禁用测试类、也可以禁用测试方法 注意:IDEA 不支持,maven 构建才支持 import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Tag; import
阅读全文
摘要:通过 Tag 对用例分组: 环境分组: 测试环境、预发布环境 阶段分组: 冒烟用例 版本分组: V1.1、V1.2 设置标签 根据标签执行 结合 Maven 执行 结合测试套件执行 import org.junit.jupiter.api.Tag; import org.junit.jupiter.
阅读全文
摘要:import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; public class RepeatedExampleTe
阅读全文
摘要:排序方式 方法排序 类排序 Suite 方法排序的类型 类型说明 OrderAnnotation(重点) @Order 注解指定排序 DisplayName 根据显示名称排序 Random 随机排序 MethodName 根据方法名称排序 import org.junit.jupiter.api.M
阅读全文
摘要:package com.mytest; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; public class NestedExampleTest { @Nested //需要结合class使用 cla
阅读全文
摘要:import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; import static java.lang.Thread.sleep
阅读全文
摘要:自动化测试过程中,需要验证某些特殊场景时,需要传空或者传null null 参数的参数化注解 @NullSource 注解 参数为空的参数化注解 @EmptySource 注解 需要 null 和空都进行参数化,使用 @NullAndEmptySource 注解 还有其他参数可以用@ValueSou
阅读全文
摘要:使用枚举类作为测试数据。 枚举参数参数化注解 @EnumSource。 必须与 @ParameterizedTest 结合使用。 需要添加@EnumSource注解 测试方法传入枚举类作为参数 package com.mytest; import org.junit.jupiter.params.P
阅读全文
摘要:通过@MethodSource注解引用方法作为参数化的数据源信息 在 @MethodSource 注解的参数必须是静态的工厂方法,除非测试类被注释为@TestInstance(Lifecycle.PER_CLASS) 静态工厂方法的返回值需要和测试方法的参数对应 如果在 @MethodSource
阅读全文
摘要:多参数参数化注解 @CsvSource。 @CsvSource 通过指定的分隔符实现参数化。 package com.mytest; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.
阅读全文
摘要:引入依赖 <!-- 参数化依赖--> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-params</artifactId> <version>5.8.1</version> <scope>tes
阅读全文
摘要:package com.mytest; import org.junit.jupiter.api.*; import static org.junit.jupiter.api.Assertions.assertEquals; public class Case2Test { //前置条件,只执行一次
阅读全文
摘要:package com.mytest; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; pub
阅读全文
摘要:<?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:sc
阅读全文