Testing COBOL code

COBOL has no test framework in the language, and this image has no COBOL test tool at all: no cobol-check, no zUnit, no GnuCOBOL test runner. What it has is a compiler, a shell, diff and gcov, which is enough to test a program properly. Every page here builds its unit and runs the tests in this container, and the page that lists the missing tools prints no output, because there was none to print.

The unit under test is a small discount subprogram with a copybook interface, so a test has something worth checking: a status, an amount in cents and a branch that the happy path never reaches. The pages are independent; read the harness first and the others in any order.

CALL A test harness in COBOL A driver program that calls the unit with a table of requests, compares the status and the cents, counts the failures and returns 1. Open sh A shell runner and exit statuses A script over a table of cases, one line per case, a failing row, and the status the script hands to a build server. Open -debug Runtime checks with -debug A loop that writes one entry past a table: the message the checked build prints, and the unchecked run whose four tests all pass. Open diff Golden files and diff A report written to a file and compared with a golden copy, the diff of a changed line, and the status of the comparison. Open gcov Coverage with gcov cobc --coverage and gcov over the generated C: 83.33% of 60 lines with the two cases that leave the unknown-code branch unvisited, and the four cases that cover it. Open none Test tools that are not here cobol-check, zUnit and the commercial frameworks: what each one is, how it would be installed, and why this page prints no output. Open