0

I am using PowerMockito.mockStatic(LogServiceImpl) in my unit test code written in SPOCK framework. Even i declared @PrepareForTest([LogServiceImpl]) at class level, i am getting org.powermock.api.mockito.ClassNotPreparedException.

Earlier it was working fine in JDK8, But when i am upgrading to open jdk 11 facing this issue.

This is the powermock version used in build.gradle file

   testCompile 'org.powermock:powermock-module-junit4-rule-agent:2.0.5'
   testCompile 'org.powermock:powermock-api-mockito2:2.0.5'

I tried the steps given in

https://github.com/powermock/powermock/issues/933

https://github.com/powermock/powermock/issues/901

Still could not resolve it.. Please help me

Rob Evans
  • 2,822
  • 1
  • 9
  • 15
Shobana
  • 41
  • 4
  • are you using junit4/5 at all? – Rob Evans Jun 10 '20 at 10:32
  • using junit 4 in my project. – Shobana Jun 11 '20 at 06:55
  • See if the info here helps you? https://automationrhapsody.com/mock-static-methods-junit-powermock-example/ More detail needed on the question - code sample would be useful. It doesn't look like a dependency issue... more like a code issue as you're getting "ClassNotPreparedException" suggesting something isn't configured correctly - possibly not using the correct `PowerMockRunner.class` but hard to say without being able to see what you've currently got – Rob Evans Jun 11 '20 at 07:55

0 Answers0