Skip to content
Dave Nicolette edited this page Jan 7, 2015 · 20 revisions

Welcome to the cobol-unit-test wiki!

Design goals

  • Support fine-grained automated unit testing of Cobol programs (individual paragraphs).
  • Enable test-driven development of Cobol code targeted to the zOS platform in isolation from the mainframe (for instance, on a laptop).
  • Ensure source-level compatibility across zOS, Unix, Linux, and Windows platforms.
  • Require no modification of production code to enable unit testing.
  • Enable developers to write tests in plain vanilla Cobol, or at worst to learn special statements that follow familiar Cobol conventions.
  • Support batch main programs.
  • Support CICS programs.
  • Support called subprograms.

Setup

If you are loading this on a system configured using https://github.com/neopragma/provision-cobol-dev-ubuntu, then clone this repo as follows:

cd ~/projects
clone https://github.com/neopragma/cobol-unit-test

If you are configuring the software yourself, then start by installing GNU Cobol. I haven't set this up on any other platforms, so I can't help you with configuration issues that may arise. Ultimately you need GNU Cobol installed and then you can clone the repo.

A brief sample

           TESTSUITE 'CONVERT COMMA-DELIMITED FILE TO FIXED FORMAT' 

      *****************************************************************
      * COBOL COMMENTS ARE IGNORED SO YOU CAN DO THIS SORT OF THING IF
      * YOU PLEASE.
      *****************************************************************  

           MOCK FILE INPUT-FILE
           MOCK FILE   OUTPUT-FILE

           BEFORE-EACH
           MOVE FOO TO BAR
           MOVE ZERO TO WS-COUNT
           END-BEFORE

           AFTER-EACH
           INITIALIZE WS-RESULTS-TABLE
           END-AFTER

           TESTCASE      'IT CONVERTS TEXT FIELD 1 TO UPPER CASE' 
           MOVE 'something' TO TEXT-VALUE-1
           PERFORM 2100-CONVERT-TEXT-FIELD-1
           EXPECT TEXT-OUT-1 TO BE 'SOMETHING'

Notes