Skip to content

Mock a CICS file read and raise a condition

Dave Nicolette edited this page Feb 19, 2021 · 11 revisions

Home -> User Guide -> Common Test Case Patterns ->

Note: This is different from the proof-of-concept implementation. We believe this model is more intuitive for Cobol programmers and more flexible for unit test purposes. Cobol Check will set the EIB fields corresponding to the condition name. We need to consider how to handle asynchronous error management (HANDLE CONDITION) and synchronous error management (NOSUSPEND). It's likely we will recommend programmers use EXPECT CONDITION x TO BE RAISED rather than expecting an error-handling paragraph to be executed, because cobol-check is not a CICS emulator, and the paragraph named in a HANDLE CONDITION command will not be performed. If we force that to happen, there is a good chance the test case will yield a false positive. Cobol-check will set EIB fields corresponding to the expected condition and will interrogate those fields when the user writes EXPECT CONDITION in the test case.

Currently this model is documentation of a design idea. It is not implemented.

    MOCK CICS DATASET 'THEFILENAME' 
        ON READ CONDITION IS NOTFND
    END-MOCK
    PERFORM PARAGRAPH-UNDER-TEST
    EXPECT CONDITION NOTFND TO BE RAISED

or

    MOCK CICS DATASET 'THEFILENAME' 
        ON READ CONDITION NOTFND
    END-MOCK
    PERFORM PARAGRAPH-UNDER-TEST
    EXPECT CONDITION NOTFND TO BE RAISED

or

    MOCK CICS DATASET 'THEFILENAME' 
        ON READ NOTFND
    END-MOCK
    PERFORM PARAGRAPH-UNDER-TEST
    EXPECT CONDITION NOTFND TO BE RAISED

or

    MOCK CICS DATASET 'THEFILENAME' 
        ON READ NOTFND
    END-MOCK
    PERFORM PARAGRAPH-UNDER-TEST
    EXPECT EIBRESP TO BE 13

or

    MOCK CICS DATASET WS-FILENAME-IN-FIELD 
        ON READ CONDITION IS NOTFND
    END-MOCK
    PERFORM PARAGRAPH-UNDER-TEST
    EXPECT CONDITION NOTFND TO BE RAISED

or

    mock cics dataset 'TheFileName'  
        on read condition is notfnd
    end-mock
    perform paragraph under test
    expect condition notfnd to be raised
Clone this wiki locally