Object Oriented JUnit Tests
summary
JUnit tests suffer from unbreakable dependencies caused by four concrete patterns: static methods, singletons, using new inside methods, and no interfaces; PowerMock can break statics but is a last resort. Ad hoc Mockito mocks bake fragile assumptions (SQL string equality causes false positives). Replace mocks with fakes/doubles — e.g., H2 in-memory DB or a fake GitHub server backed by an XML file — and prefer Hamcrest-style composite matchers so each test is one clear assert that statement.
AI-written summary · about
