Reputation: 277
I am trying to mock a static method using Powermock. The code works when I use it in Junit4, JDK8 environment. However, Powermock is not working with JDK11 and Junit5 combination. When I looked into Powermock documentation it says support has been added for Junit 4.7+. So my understanding is it should work with Junit5. There is no mention of JDK. So it Will support Java irrespective of version?
I have tried using various combinations of Powermock with Junit5 in pom.xml. But nothing seems to be working. Can anyone help me with the working combination(dependencies) of Powermock, Junit5 and JDK11? Will this combination even work together?
Edit: I saw somewhere that Junit5 doesn't work with Powermock. But it is a post from 2018. Is the support provided yet as of 2020? Any information on this would be of much help.
Upvotes: 6
Views: 9148
Reputation: 277
I have spent 3 days on this trying different combinations. As of 2020 February, I believe there is no support for Powermock with Junit5. So, the better alternate is to go for Jmockit. I have done mocking static methods using Jmockit.
I thought of writing this because it may save someone's day. Although, if anyone has done mocking static methods in Powermock Junit5 combination. Please post it.
Upvotes: 15