Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> By enabling isolation in the test, mocking reduces the pressure to design more isolated code.

Having just written some tests (with mocks) today, I have read your comment several times and failed to extract any meaning whatsoever from it. It seems like the kind of comment that's counter-intuitive because it's just nonsense. Mocking reduces isolation by enabling isolation? Um.

> Redesign your code so it only interacts with such code at the edges.

Yes, and those edges can then be mocked when you want to test the rest of the code. Apis, interfaces etc. are a good fit to mocking. Mocking helps isolation.

TFA's argument seems to be that they ended up not needing a database, and if they'd have "used mocking" they would have started by mocking the database, therefor mocking encourages bad design. Nope, starting with things that you don't need yet encourages bad design. It doesn't matter if you're mocking those things or not.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: