1

I am trying to run an integration test using junit4 for which I need to use @RunWith(SpringRunner.class) but I also need to use @RunWith(RunIfRunner.class) for implementing the solution mentioned here

How to ensure the use of both on these? Or is there any other way to deal with this other than using @RunWith()?

Note: I need to use the solution mentioned in the link above(check here - 1).

  • You don't you can only have 1 runner. I believe there is a JUnit rule to mimic (Partially) the `@RunWith` so you could combine one with the other. Or ditch this approach and move to JUnit5 for which you can quite easy write conditional tests without the need for additional extensions. – M. Deinum Jan 11 '23 at 11:47
  • 1
    The particular `Runner` implementation would have to support delegating to an arbitrary other `Runner`. – Holger Jan 11 '23 at 15:12
  • @M.Deinum, I can't switch to junit5 as RunIfRunner.class is implemented with junit4. Any idea how to implement something like this for my case - https://stackoverflow.com/questions/24431427/multiple-runwith-statements-in-junit/24431738#24431738 – Dhanyaa Bharadwaj Jan 12 '23 at 06:06
  • @Holger how to implement that? – Dhanyaa Bharadwaj Jan 12 '23 at 06:07
  • You don't need `RUnIfRunner` with JUnit5 as conditionally running tests is part of JUnit5. So yuou don\t need all the extra stuff as it is build into the framework! – M. Deinum Jan 12 '23 at 06:15

0 Answers0