Hacker News new | past | comments | ask | show | jobs | submit login

I completely agree with David's assertion that there is too little focus paid to how to test properly or what over-testing looks like.

Here's a question to the HN community... For a library you write yourself to, say, access a Web service, how do you go about testing it? (For example, if you want to write tests against an Akismet gem)

I tend to write both unit tests and integration tests for it. My unit tests mock out the HTTP calls made by the library and only test that the library is able to handle both good and bad inputs.

My integration tests allow the library to speak directly to the web service in question, to test that the correct connection is being made and the service is providing the correct data back to the library.

Is this overkill?




I'd have to lean toward yes and here's why:

1) Config, connections, or whatnot are one-time only. You're not going to screw up many times.

2) Not all WebServices have their own test-server so count yourself lucky if the ones you use have them :)

3) You're testing their code instead of yours if you have to make sure correct data etc comes back.

I usually only write unit-tests if they came back with bad data and we did not anticipate it (edge-case situation).




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

Search: