问题描述
是否有一种干净的方法来运行参数化的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.Parameterized
由org.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测试,无需更改流道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!