Data Input / Output and JUnit
[Practical 8 of 11]


This practical will examine how to build a simple read and write utility for your models. The example will be very simplistic but more complexity will be introduced for you to consider.

The Junit framework will be used to demonstrate the benefits of test driven development. Test driven development is a professional programming approach where a series of tests are first designed to ensure the behaviour of a method is as desired. The tests cover not just what should happen when all is working well but also what should happen when unexpected conditions are encountered.

The behaviour of the method is outlined prior to starting to write the actual code. Test methods are developed which identify if the behaviour of the actual method is as expected under certain conditions.

The benefits of test driven development are:

The main drawback to test driven development is that it is time consuming in the initial development stages. However, the time investment is paidback through when code is revisited for enhancement or maintainance.

This practical will introduce a simple set of test conditions and some simple methods to satisfy that test. We will start by building a simple data reading package for csv files.


Continue to part 1 of the practical