top | item 46414647

(no title)

totallykvothe | 2 months ago

Mockito allows one to write mocks in tests for code that doesn't use dependency injection and isn't properly testable in any other way.

On the one hand, you should just design things to be testable from the start. On the other... I'm already working in this codebase with 20 years of legacy untestable design...

discuss

order

deepsun|2 months ago

Google API libraries mark every class as "final" so it's not trivial to mock-extend it for tests. But third-party IO is exactly the thing you'd want to mock.

Probably because they zealously followed "Effective Java" book.

wiseowise|2 months ago

> But third-party IO is exactly the thing you'd want to mock.

You write an adapter.