A Java geek
  • Me
  • Books
  • Speaking
  • Mentions
  • Focus
  • Newsletters

powermock

A collection of 3 posts
Refactoring code for testability: an example
Java

Refactoring code for testability: an example

Working on a legacy project those last weeks gave me plenty of material to write about tests, Mockito and PowerMock. Last week, I wrote about abusing PowerMock. However, this doesn’t mean that you should never use PowerMock; only that if its usage is commonplace, it’s a code smell. In this article, I’d like to show an example how one can refactor legacy code to a more testable design with the temporary help of PowerMock.

Dec 20, 2015
PowerMock logo
Java

On PowerMock abuse

Still working on my legacy application, and still trying to improve unit tests. This week, I noticed how much PowerMock was used throughout the tests, to mock either static or private methods. In one specific package, removing it improved tests execution time by one order of magnitude (from around 20 seconds to 2). That’s clearly abuse: I saw three main reasons of using PowerMock.

Dec 13, 2015
PowerMock, features and use-cases
Java

PowerMock, features and use-cases

Even if you don’t like it, your job sometimes requires you to maintain legacy applications. It happened to me (fortunately rarely), and the first thing I look for before writing as much as a single character in a legacy codebase is a unit testing harness. Most of the time, I tend to focus on the code coverage of the part of the application I need to change, and try to improve it as much as possible, even in the total lack of unit tests.

Oct 7, 2012
A Java geek © 2008-2026
v. 9744a65fcb2ff5057d025d26766c50d6f934fc0b/13747693232
Latest Posts