Saturday, July 30, 2011

testing

Prompted by a psychologist friend, I'm writing a mood tracking app in Java, to refresh my Java skills.

In the progress, I thought I'd try to write the test cases as I designed and programmed the application.
I've never used any proper testing frameworks, so I'm starting with the easily available JUnit.

There seems to be a lot of information available on effective ways to write tests.

The interesting thing about writing a test is that you have to be very clear about what behavior you are expecting. So you must have a clear idea of what you are trying to build and then test. This forces you to clarify the requirements before programming.

It may be difficult to pin down the requirements in advance sometimes. If you are just trying stuff out or just experimenting with functionality, you may not want to fix the outcome in advance.
However, even in such cases, it can be good to limit the functionality temporarily, write test cases for this temporary target, and modify the test cases as you adjust the functionality. It does depend on your individual programming style though.

No comments: