Skip to content

How Cobol Check Works (Overview)

Dave Nicolette edited this page Feb 10, 2021 · 6 revisions

Home -> User Guide ->

Cobol-check runs as a precompiler. It merges the source code of the program under test with one or more test suites and test case management logic to produce a copy of the program under test that has all the test code embedded in it. The copy is then compiled and executed.

Test case management code is inserted at the top of the Procedure Division of the program under test. It executes selected paragraphs within the program under test, as called-for in the test cases. In that way, cobol-check is able to exercise individual paragraphs without running the entire program.

Test suites are coded in a Cobol-like DSL (domain-specific language) that is meant to be intuitive for Cobol programmers. Thus, test case syntax looks different from test cases written for xUnit-style frameworks in other programming languages. This is not an xUnit-style framework, as that approach will not work for mainframe-based procedural languages.

cobolcheck

Convention over configuration

The simplest way to set up downloaded programs for testing is to place them in the directories where cobol-check expects to find them by default.

project-root/ 
  |
  +-- src/main/cobol/
  |     |
  |     +-- copy/         <- copybooks
  |     | 
  |     +-- program1/ 
  |     |     |
  |     |     +-- program1.cbl 
  |     | 
  |     +-- PROGRAM2/ 
  |           |
  |           +-- PROGRAM2.CBL 
  |
  +-- src/test/cobol/ 
        |
        +-- program1/ 
        |     |
        |     +-- testfile1-1  
        |     | 
        |     +-- testfile1-2 
        |
        +-- PROGRAM2/ 
              |
              +-- testfile2-1  
              | 
              +-- testfile2-2 

Optionally, you can set different values in config.properties to control where cobol-check looks for files and what the filename suffixes are:

application.source.directory 
application.source.filename.suffix 
application.copybook.directory 
application.copybook.filename.suffix 
test.suite.directory

Testing a subprogram

To test a subprogram, it is necessary for the user to write a trivial driver (a main program) to call the subprogram. Cobol-check does not attempt to build a driver automatically or to deal with the Linkage Section in any special way. That level of manipulation of the code under test might result in unintended behaviors that yield unreliable test results.

Clone this wiki locally