0

I am trying to use powermock and mockito with spring. I have used them before but without spring. Spring-cloud-stream-test-support already provides the JUnit4.12 , and some other dependencies come with it. Mockito is also running fine with this version of JUnit.

But, I have to mock some static method calls, so I need to use Powermock. I have tried to include Powermock with these versions of JUnit and Mockito.

  • junit:junit:4.12
  • org.mockito:mockito-core:2.8.0
  • org.powermock:powermock-api-mockito2:1.7.0RC2
  • org.powermock:powermock-module-junit4:1.7.0
  • org.powermock:powermock-core:1.7.0
  • org.powermock:powermock-module-junit4-rule:1.7.0

as suggested by this answer. But there is no Mockito-core:2.8.0. So, I tried to combine it with other versions, but they all throw some kind of hard to resolve exception.

For example, I tried, Mockito-Core:2.8.9, it throws,

java.lang.NoSuchMethodError: org.mockito.mock.MockCreationSettings.getConstructorArgs()

Mockito-all comes with mockito-core, but when I dont provide mockito-core explicitly, it throws,

java.lang.NoSuchMethodError: org.mockito.mock.MockCreationSettings.getConstructorArgs()

I have tried to isolate the errors and trace them to issues in that testing framework version, but that seems to never end. Can someone suggest what are the compatible versions?

KumarAnkit
  • 713
  • 1
  • 9
  • 26

1 Answers1

0

Powermock and Mockito versions compatibility can be checked on this link. But I could not find the Junit and Mockito versions compatibility anywhere. Please start exploring the coolest Junit5 features. Junit5 bom link and the migration guide from Junit4 to Junit5

Prasanth Rajendran
  • 4,570
  • 2
  • 42
  • 59
  • Thanks, but I already tried the versions as described in your answer, does not work however. That could have been the issue with Spring version which I was using. – KumarAnkit Dec 13 '19 at 13:39
  • @KumarAnkit have you found the mockito and Junit5 versions compatibilities? It would be helpful if there are any. – Prasanth Rajendran Dec 13 '19 at 13:42