What does the annotation @PrepareForTest in PowerMockito really mean?
@PrepareForTest
What should be placed there apart of classes which have static methods?
That annotation tells PowerMock(ito) that the listed classes will need to be manipulated on the byte code level.
You need to "prepare for test" all these classes X of which you want to
new()
PowerMockito.when(spy, "privateMethodNameAsString").then...
In other words:
X.doStatic()
new Y(...)
new
2.1m questions
2.1m answers
60 comments
57.0k users