-
Notifications
You must be signed in to change notification settings - Fork 32
Test Suite Syntax
Home -> User Guide -> General User Guide ->
Cobol-check uses a domain specific language (DSL) for specifying unit tests. The DSL is intended to resemble Cobol source code, so it will be intuitive for Cobol programmers to use, but it is not actually Cobol and will not compile. The test suites have to be pre-processed to produce a Cobol source file that contains all the test cases.
Modern Cobol source on most platforms is free-form, but the traditional source line format is still relevant on z/OS systems as the rest of the environment still has the original System 360 design elements at heart.
The cobol-check DSL is mostly free-form, except that you place an asterisk in column 7 to denote a comment line. Test suites will be most readable if you adhere to the Area A / Area B convention, but there are no "rules" about whether to place a keyword such as TESTCASE in Area A or Area B. In general, we find it helpful to write TESTSUITE and TESTCASE in Area A and the other DSL statements in Area B, and to leave a blank line between test cases.
When the pre-processor interprets test suite input files, it reads them character-by-character rather than line-by-line. That means you have a degree of freedom for source format. In particular, it means you needn't worry about writing continuation lines for long alphanumeric literals. The pre-processor will insert those lines into the test program source in the appropriate way. You can code long, descriptive names for test suites and test cases without worrying about over-running column 72.
Cobol-check is case-agnostic.
Most of the sample code is written in uppercase letters. This is not required. These are equivalent:
TestCase "When message type is greeting it returns 'Hello, World!'"
SET MESSAGE-IS-GREETING TO TRUE
PERFORM 2000-SPEAK
Expect WS-GREETING To Be "Hello, World !"
testCASE "When message type is farewell it returns See you later, alligator!"
SET MESSAGE-IS-FAREWELL TO TRUE
PERFORM 2000-SPEAK
expect WS-FAREWELL to be "See you later, alligator!"
More info TBD.