摘要: 使用枚举类作为测试数据。 枚举参数参数化注解 @EnumSource。 必须与 @ParameterizedTest 结合使用。 需要添加@EnumSource注解 测试方法传入枚举类作为参数 package com.mytest; import org.junit.jupiter.params.P 阅读全文
posted @ 2023-08-23 23:15 Mr_sven 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 通过@MethodSource注解引用方法作为参数化的数据源信息 在 @MethodSource 注解的参数必须是静态的工厂方法,除非测试类被注释为@TestInstance(Lifecycle.PER_CLASS) 静态工厂方法的返回值需要和测试方法的参数对应 如果在 @MethodSource  阅读全文
posted @ 2023-08-23 23:07 Mr_sven 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 多参数参数化注解 @CsvSource。 @CsvSource 通过指定的分隔符实现参数化。 package com.mytest; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params. 阅读全文
posted @ 2023-08-23 23:02 Mr_sven 阅读(381) 评论(0) 推荐(0) 编辑
摘要: 引入依赖 <!-- 参数化依赖--> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-params</artifactId> <version>5.8.1</version> <scope>tes 阅读全文
posted @ 2023-08-23 22:48 Mr_sven 阅读(60) 评论(0) 推荐(0) 编辑