首页 > 其他 > 详细

junit5使用参数化注解时报错

时间:2021-06-15 21:21:15      阅读:18      评论:0      收藏:0      [点我收藏+]
junit5使用参数化注解@ParameterizedTest、@CsvSource注解时遇到的问题: 1.无法使用@ParameterizedTest、@CsvSource注解,原因是pom.xml文件中缺少junit5的依赖 解决方法:pom.xml文件中加入以下依赖: ` org.junit.jupiter junit-jupiter-params 5.6.2 test ` 2.使用@ParameterizedTest、@CsvSource注解后报如下错误: ![](https://img2020.cnblogs.com/blog/2100592/202106/2100592-20210615170434590-1211268905.png) 原因:也是junit依赖包的问题 解决方法,导入以下junit相关依赖包: ` org.junit.jupiter junit-jupiter-engine 5.6.2 org.junit.platform junit-platform-runner 1.6.2 org.junit.jupiter junit-jupiter-api RELEASE test org.junit.platform junit-platform-launcher 1.6.2 test org.junit.jupiter junit-jupiter-engine 5.6.2 test org.junit.vintage junit-vintage-engine 5.6.2 test org.junit.jupiter junit-jupiter-params 5.6.2 test ` 3.使用参数化后断言问题,使用assertTrue断言 注意导包:import static org.junit.Assert.*; 示例: `package Test; import Interfaces.LoginTest; import io.restassured.response.Response; import static org.junit.Assert.*; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; public class Login { @ParameterizedTest @CsvSource({ "13536764015, 123456", "18475465437, 123456", "18475465438, 123456" }) public void loginTest(String mobile,String password){ // String mobile="13536764015"; // String password="123456"; Response loginResponse = LoginTest.loginByiMobile(mobile,password); Integer stateCode = loginResponse.path("stateCode"); String access_token=loginResponse.path("data.access_token"); assertTrue (stateCode.equals(200)); System.out.println(access_token); } }`

junit5使用参数化注解时报错

原文:https://www.cnblogs.com/jina1121/p/14886260.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!