参数化的jUnit测试,无需更改流道 [英] Parameterized jUnit test without changing runner

查看:86
本文介绍了参数化的jUnit测试,无需更改流道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种干净的方法来运行参数化的jUnit 4测试,而无需更改运行器,即不使用 @RunWith(Parameterized.class)?

Is there a clean way to run parameterized jUnit 4 tests without changing the runner, i.e. without using @RunWith(Parameterized.class)?

我的单元测试已经需要一个特殊的运行器,并且我不能用Parameterized代替它.也许有某种跑步者连锁",所以我可以同时参加两个跑步者吗? (只是一个疯狂的猜测...)

I have unit tests which require a special runner already and I can't replace this one with Parameterized. Maybe there is some kind of "runner chaining" so I could both runners at the same time? (Just a wild guess...)

推荐答案

org.junit.runners.Parameterizedorg.junit.internal.builders.AnnotatedBuilder通过反射机制创建.也许您可以将Parameterized扩展为自己的运行程序:@RunWith( MyParameterized .class).

org.junit.runners.Parameterized is created by org.junit.internal.builders.AnnotatedBuilder by reflect mechanism. Maybe you could extend Parameterized as your own Runner: @RunWith(MyParameterized.class).

这篇关于参数化的jUnit测试,无需更改流道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆