2

I am upgrading my JUnit to version 5 and I get this error when I run the JUnit 5

I am using in my pom

<dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
</dependency>
<dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
</dependency>

org.powermock.api.mockito.ClassNotPreparedException:

[Ljava.lang.Object;@723ca036 The class com.xxxxxx.MyClass not prepared for test.

I am using @RunWith(JUnitPlatform.class) for my class test notation

My code is

PowerMockito.mockStatic(MyClass.class);
when(MyClass.get(anyString()))
    .thenReturn(mock);
Hiren Gohel
  • 4,942
  • 6
  • 29
  • 48
yenk
  • 219
  • 2
  • 12
  • 2
    Possible duplicate of [Powermock throws ClassNotPreparedException when using JUnit 5](https://stackoverflow.com/questions/51779581/powermock-throws-classnotpreparedexception-when-using-junit-5) – Svetlin Zarev Mar 05 '19 at 07:43

1 Answers1

0

You have to use ExtendWith. In junit 5 the annotation gets @RunWith changed to

@ExtendWith(JUnitPlatform.class)

Further details on how to use Extend with