Software testing (in Java) from the beginning
Viera K. Proulx · Journal of computing sciences in colleges · 2012
Software testing is usually delegated to upper level courses when students work on larger projects and practice design skills. We believe that software testing needs to be an integral part of learning how to design programs from the very beginning. The goal of this workshop is to show how with the proper software support students can practice test-first design from the beginning, and show that this approach helps students to develop good program design habits early. We then show how additional techniques can be used to create a more comprehensive validation and verification of programming projects and help in identifying design flaws in student projects. In the first half of the workshop we will introduce unit testing for the beginners, both in the functional style and in the imperative style, exploring the notion of equality, and examining special cases of unit testing (checking the correctness of constructors, methods that throw exceptions, tests for inexact values, for a range of values, or one-of values, tests that compare structured data sets. We will introduce our tester library that makes test design, evaluation, and reporting accessible to the programmer at his/her current level of knowledge of programming. We will show the syntax for the tests and describe the pedagogy we use to enforce test-first design from the very first program students write. The tester library is freely available on our web site with extensive documentation that shows how to use it with Eclipse, NetBeans, BlueJ, or just command-line Java compilation. In the second half of the workshop we will show how to design randomized tests, stress tests, black box tests and integration tests. We will show how the use of tools that measure code metrics can help students and instructors identify design flaws in student projects that make the design of tests difficult or impossible. We have used these tools in our courses, especially in code reviews and in evaluation of student projects with promising results.