简体   繁体   中英

JUnitParamsRunner with Guice

I have a java test which is based on guice. I want to pass multiple parameter sets which are supported by JUnitParams . But it looks like I can pass only one @RunWith . So essentially I can add either JUnitParamsRunner or GuiceTestRunner . What is the way out?

No, you cannot have multiple runners for one test class - this is a limitation of JUnit 4. You can however have a runner and multiple Rule s. There is no official Rule for Guice, but you can find a few third-party solutions (eg. here or here ) or write your own. That way you can have a test class that is annotated with @RunWith(JUnitParamsRunner.class) and has a @Rule field that sets up Guice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM