boot spring 对参数检测_spring-boot+junit 参数化测试

1、junit 参数测试四个步骤

a、对测试类添加注解 @RunWith(Parameterized.class)

029dee34da08

b、将需要使用变化范围参数值测试的参数定义为私有变量

029dee34da08

c、 使用上一步骤声明的私有变量作为入参,创建构造函数

029dee34da08

d、创建一个使用@Parameters 注解的公共静态方法,它将需要测试的各种变量值通过集合的形式返回。

029dee34da08

e、使用定义的私有变量定义测试方法

029dee34da08

2、@RunWith(Parameterized.class)和@RunWith(SpringRunner.class)二选一

使用参数化测试要用@RunWith(Parameterized.class),而springboot测试要用RunWith(SpringRunner.class),且

RunWith只能选一个,所以百度一番找到一个讲解怎么实现的的博客。

按照博客中指出的方式手动启动一个spring容器 但是还是报下列错误You can possibly workaround the problem by overriding the org.junit.runners.ParentRunner#filter by extending the Parameterized

扩展Parameterized类后测试类正常运行。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值