The following example tests if a file can be written to. If there is a problem writing to the file (for example, the file does not exist or is locked), the test will fail.
Compile the program to .so (see Compiling Tests), then run the resulting test suite (see Running Tests).
$set case program-id. TestCases. environment division. input-output section. file-control. select cust assign to 'cust.txt' organization is line sequential. data division. file section. fd cust. 01 cust-file. 03 customer-id pic 9(5). 03 customer-info pic x(65). working-storage section. copy "mfunit.cpy". procedure division. goback. entry MFU-TC-PREFIX & "FullTestCase". *> the test case move 0 to customer-id perform 100 times add 1 to customer-id move "A customer" to customer-info write cust-file end-perform goback. entry MFU-TC-SETUP-PREFIX & "FullTestCase". *> the test case setup open output cust goback entry MFU-TC-TEARDOWN-PREFIX & "FullTestCase". *> the test case teardown close cust goback end program.