Search code examples
javajunitmockingjava1.4

How can I mock static methods in Java 1.4?


I'm using JUnit with Mockito. PowerMock can mock static methods but it doesn't seem to be possible to use it with Java 1.4, specially since it needs annotations.

Is there any other alternative?

Thanks.


Solution

  • (Shameless self promotion here) There is a project PowerMock-Legacy that lets you use PowerMock in Java 1.4. It is a bit verbose, and not all functionality is supported, but may worth a try.