Random data in Unit Tests?

There’s a compromise. Your coworker is actually onto something, but I think he’s doing it wrong. I’m not sure that totally random testing is very useful, but it’s certainly not invalid. A program (or unit) specification is a hypothesis that there exists some program that meets it. The program itself is then evidence of that … Read more

How do I test a class that has private methods, fields or inner classes?

If you have somewhat of a legacy Java application, and you’re not allowed to change the visibility of your methods, the best way to test private methods is to use reflection. Internally we’re using helpers to get/set private and private static variables as well as invoke private and private static methods. The following patterns will … Read more