Test-First Java
The majority of introductory programming courses that use Java provide only a minimal or no introduction to unit testing. The main reason for this is that using the JUnit testing framework requires that students learn yet another set of techniques and tricks, and that students need to understand early on the nuances of defining equality of two objects (e.g. are the two objects identical, or do they represent the same values, or do they refer to identical objects, or objects whose values are the same...)
Our tester library provides a novice-friendly environment for the design of tests for Java programs. The tests are written as a code that the program user would write. The programmer defines an Examples class that behaves as a client to the student’s code: it includes the sample data definitions for all classes defined in the program that is to be tested, and the test methods for all methods defined in the program. The test methods consist of method invocations (by sample data objects defined in this class) paired with the expected results. For methods that have no side effects this is very straightforward. For methods that have effects (and may be void, i.e. not producing any values) the test method consists of setting up the needed data, invoking the method, and then evaluating the expected effects.
The tester library has been used
successfully in courses that follow a variety
of curricula —
Additional materials that cover more advanced sotfware testing concepts have been used in our courses and presented at our summer faculty development workshops.
Watch the tester web site for tutorials on the use of the tester library in a variety of contexts, look us up and find the sources and downloads at our github site and follow us on Twitter at TestFirstJava. _________________________________________________________________________________
This project is supported by the
NSF DUE Integrating Test Design into Computing Curriculum from the Beginning Grant # 0920182
NSF DUE Redesigning Introductory Computing: The Design Discipline Grant # 00618543