logoalt Hacker News

MBCooktoday at 3:28 AM0 repliesview on HN

I like Mockito, it’s useful, but I’ll never understand mocking out DB stuff.

Why fake it when an integration test tests the real thing.

I’ve seen what you clearly have. Mocked ResultSets, mocked JDBC templates. “When you get SQL, it should be this string. These parameters should be set. Blah blah.”

It’s so much work. And it’s useless. Where does that SQL to check come from? Copy and paste, so it won’t catch a syntax error.

Test data is faked in each result. You can’t test foreign keys.

Just a bad idea. You’re so right. I find it odd some people are so anti-mock. Yeah it gets abused but that’s not the tool’s fault.

But DB calls are not a good spot to mock out.