次の例では、ファイルへの書き込みが可能かどうかをテストします。ファイルへの書き込みに問題がある (ファイルが存在しない、またはロックされている) 場合、テストは失敗します。
プログラムを .dll にコンパイルし (「テストのコンパイル」を参照)、次に結果のテスト スイートを実行します (「テストの実行」を参照)。
$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.