Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror

Comment Re:Useless (Score 1) 147

I don't believe that code using 3rd party APIs requires either setting up a complex environment or mocking things out. And I see no reason the code should be tested in isolation of third party APIs. If the code uses the third party APIs, so should the tests.

I routinely write tests that access various external APIs such as SAX, DOM, and QuickTime for Java. Some of the time what I'm testing for are workarounds for bugs in specific third party APIs. Perhaps some third party APIs require complex setup (DOM isn't trivial) but that's what fixtures are for.

Really the question of 3rd part APIs is completely orthogonal to the question of complex setup. Some APIs have complex setup. Some don't. Some APIs are third party. Some aren't. And these come in all combinations and flavors.

There are times mock objects are appropriate. I don't want my database tests to affect the production server; but maybe I do want them to hit a real database, not some pseudo thing that doesn't behave like a real database behaves. I want my tests to tell me as much as possible about how my code will operate under real conditions. The more I mock out, the less confidence I have that code works when it has to run in the real world instead of the mock world I've invented.

Slashdot Top Deals

"In order to make an apple pie from scratch, you must first create the universe." -- Carl Sagan, Cosmos

Working...