-
Notifications
You must be signed in to change notification settings - Fork 28
Approach to Mocks
Dave Nicolette edited this page Jan 29, 2021
·
28 revisions
Home -> Development Guide -> Implementation Notes ->
As of January 2021, support for mocks has not been implemented in Cobol Check.
We want to take a slightly different approach than was taken in the proof of concept project, cobol-unit-test. In that project, a mock represented behavior, such as reading a file or calling a subprogram. In Cobol Check, a mock represents (or will represent) an external resource - a file, a subprogram, etc. - and the user can specify one or more behaviors for that resource. We expect this approach to be easier for users and less error-prone than the previous approach.
Here are some examples of how users might code Mocks in Cobol Check (subject to change as development continues).
TestCase "It handles file-not-found"
mock Taxpayer-Update-File
on open file-status is file-not-found
end-mock
perform 1100-open-files
expect w-error-code to be "TUFNOTFND"
TestCase "It handles missing postal code"
mock Taxpayer-Update-File
on read
move "testID123" to tp-in-taxpayer-id
move "55 main st." to tp-in-taxpayer-addr1
move "bakersfield, ca" to tp-in-taxpayer-addr2
move spaces to tp-in-taxpayer-postcode
end-mock
perform 1500-validate-in-rec
expect ws-error-code to be "TUFNOPOST"