Chapter 6. Drivers of Testability
Some constructs and behaviors in code have great impact on its testability. This chapter is about exploring and harnessing them. Let’s start by looking at two snippets of code. The first one—matrix multiplication—is a typical programming exercise for fresh computer science students.
static multiply(double[][] m1, double[][] m2) { if (m1[0].length != m2.length) { throw new IllegalArgumentException( "width of m1 must equal height of m2" ) } final int rh = m1.length final int rw = m2[0].length double[][] result = new double[rh][rw] for (int y = 0; y < rh; y++) { for (int x = 0; x < rw; x++) { for (int xy = 0; xy < m2.length; ...
Get Developer Testing: Building Quality into Software now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.