Equivalent for @RunWith(JUnitPlatform.class) for JUnit5

11,335

Solution 1

You don't need it anymore when using junit 5.

In the junit documentation it states:

Annotating a class with @RunWith(JUnitPlatform.class) allows it to be run with IDEs and build systems that support JUnit 4 but do not yet support the JUnit Platform directly.

So since you are migrating to junit 5 I suppose your build system/IDE supports it. Hence, you don't need the annotation anymore.

Solution 2

Junit4 @RunWith has been replaced by @ExtendWith in JUnit5 as of content from https://www.baeldung.com/junit-5-runwith

Share:
11,335
Szymon Żak
Author by

Szymon Żak

Updated on June 05, 2022

Comments

  • Szymon Żak
    Szymon Żak almost 2 years

    In my project I'm doing some cleanup and decided to move everything to JUnit5.

    Till this time, I was using

    @RunWith(JUnitPlatform.class)
    

    Now I want to migrate it to @ExtendWith. Is there any equivalent for this JUnitPlatform.class in JUnit5?

  • Szymon Żak
    Szymon Żak over 4 years
    Ok, thanks. I have another fast question. CamelSpringBootRunner and CamelSpringRunner aren't migrated yet and I can't just simply delete it like JUnitPlatform?
  • Dries Thieren
    Dries Thieren over 4 years
    You won't be able to migrate those to junit 5 then.
  • Dries Thieren
    Dries Thieren over 4 years
    (until Camel decides to resolve this issue: issues.apache.org/jira/browse/CAMEL-11807)
  • Fabio
    Fabio about 4 years
    so what would I do if I wanted to run an android project test with Robolectric? I usually would do @RunWith(RobolectricTestRunner::class)