Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support jUnit5 #830

Open
thekingn0thing opened this issue Aug 7, 2017 · 14 comments · May be fixed by #1146
Open

Support jUnit5 #830

thekingn0thing opened this issue Aug 7, 2017 · 14 comments · May be fixed by #1146
Labels
Milestone

Comments

@thekingn0thing
Copy link
Member

Waiting while junit team will implement an extension for specifying class loader junit-team/junit5#201

@DJViking
Copy link

DJViking commented Feb 6, 2019

Powermock 2.0.0 has been released, but is this fixed?

@DJViking
Copy link

Seems Powermock 2.x does not have JUnit 5 support.
I hope this could be targeted for the next release 2.1 of Powermock.

@Frontrider
Copy link

Frontrider commented Apr 17, 2019

I was pointed at this, I'll look into it when I can.
junit-team/junit5#157

beatngu13 added a commit to retest/recheck that referenced this issue Aug 26, 2019
PowerMock currently doesn't support JUnit 5: powermock/powermock#830.
@AlexJuca
Copy link

Any updates regarding junit5 5 support?

@ghost
Copy link

ghost commented Oct 16, 2019

Any update on this? Can you guyz (devs) please share the status??

@gtskaushik
Copy link

Team, I am in need of this feature very badly

@brandon1024
Copy link

This is blocking our team from migrating to JUnit 5. Would really like to see this work soon.

@hitsmaxft
Copy link

4 years passed . it seem's that JUnit5 team just started discussing about custom classloader feature recently. : P

@Vampire
Copy link
Contributor

Vampire commented Apr 19, 2020

You actually can by a little trick and this should work with any JUnit platform based tests, not only Jupiter tests.

Believe it or not, but it indeed is the PowerMockRunner.
It is a bit from behind through the chest in the eye, but it works.

JUnit 5 has a JUnit 4 runner called JUnitPlatform, that lets you run any JUnit platform based test in a JUnit 4 environment, so that you can use JUnit platform based tests in environments (IDEs, build tools, CI servers, ...) that do not yet naturally support JUnit platform.

Leveraging this, this works:

  • Annotate your test class with @RunWith(PowerMockRunner) to run through the PowerMock runner
  • Annotate your test class with @PowerMockRunnerDelegate(JUnitPlatform) to instruct the PowerMock runner to delegate to the runner that runs the JUnit platform based test
  • Make sure your test executor executes tests with JUnit 4

I tested this with Gradle and Spock 2.0-M2 and it works perfectly fine.
If there is some auto-detection like "If it is @Testable run with JUnit 5 else, ..." and no way to select the JUnit version manually, you might be at loss.
But then you always have the choice to switch to Gradle where the choice is explicit. :-D

@zdenek-jonas
Copy link

What is the current status of this feature? Thank you.

@Djaytan
Copy link

Djaytan commented Nov 27, 2022

Here is my sharing about what I understood about the state of the JUnit 5 support for Powermock:

After doing some searches in all related discussions around the migration of Powermock to JUnit 5, I conclude the problem is located in JUnit 5 side and won't be fixed, or at least not in a near future according to the path followed until now.

Even after a long discussion of several years and event with the important involvement of Powermock team no solution as been implemented yet (121 comments since 2016 at the time I post this message).

So, this is why this Powermock epic still blocked...

@marcphilipp
Copy link

I submitted a PR that adds a JUnit Jupiter extension that works with the existing Java agent without requiring any changes in JUnit in #1146.

@manojnamodurai
Copy link

I submitted a PR that adds a JUnit Jupiter extension that works with the existing Java agent without requiring any changes in JUnit in #1146.

PowerMock contributors / @thekingn0thing / @johanhaleby, Adding this comment to get attention on this PR. Thank you!

@ehtiramabdullayev
Copy link

Is it still the case? Any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
PowerMock 2.x
  
To Do
Development

Successfully merging a pull request may close this issue.