Quiz: Unit Testing COBOL

Multiple Choice

1. What is the primary reason COBOL programs have historically lacked automated unit tests?

a) COBOL cannot be tested automatically b) COBOL programs are too large to test c) The concept of automated unit testing postdates most COBOL code, and the ecosystem developed without it d) Unit testing only works with object-oriented languages

2. In the COBOL-Check framework, what does the .cut file extension stand for?

a) COBOL Utility Test b) COBOL Unit Test c) COBOL Unified Testing d) Custom Unit Test

3. How does COBOL-Check execute tests against a COBOL program?

a) It runs tests as a separate program that calls the program under test b) It injects test code directly into the source program, creating a merged program c) It interprets the COBOL source without compilation d) It converts COBOL to Java and uses JUnit

4. In the Arrange-Act-Assert pattern for COBOL, the "Act" step is typically:

a) MOVE values to WORKING-STORAGE b) PERFORM the paragraph under test c) Compare actual values to expected values d) OPEN the input file

5. Which of the following is NOT a valid COBOL-Check assertion?

a) EXPECT WS-FIELD TO BE 42 b) EXPECT WS-FIELD TO BE GREATER THAN 100 c) EXPECT WS-FIELD TO MATCH REGEX "[0-9]+" d) EXPECT WS-FIELD TO BE NUMERIC

6. What is equivalence partitioning?

a) Dividing the program into equal-sized paragraphs b) Splitting test data into classes where values should produce similar behavior c) Partitioning VSAM files for parallel testing d) Distributing tests across multiple JCL jobs

7. In boundary value analysis for a field PIC 9(3) with valid range 1-999, which values should you test?

a) 0, 1, 500, 999, 1000 b) 1, 500, 999 c) 0, 1, 2, 998, 999, 1000 d) Any three random values in the range

8. What is the COBOL equivalent of "dependency injection" for testing?

a) Using COPY REPLACING to modify field names b) Linking the program under test with stub subprograms instead of real ones c) Modifying the PROCEDURE DIVISION USING clause d) Using DYNAMIC calls with overridden library paths

9. Which type of code coverage measures whether both TRUE and FALSE branches of every IF statement are tested?

a) Statement coverage b) Path coverage c) Branch coverage d) Paragraph coverage

10. In a CI/CD pipeline for COBOL, what is the correct order of steps?

a) Compile, Test, Checkout, Deploy b) Checkout, Generate Tests, Compile, Execute Tests c) Test, Compile, Deploy, Checkout d) Generate Tests, Checkout, Test, Compile

Short Answer

11. Explain why testing a COBOL paragraph is fundamentally different from testing a Java method. What specific characteristics of COBOL paragraphs make testing challenging?

12. Describe two approaches to handling file I/O dependencies when unit testing a COBOL program. What are the trade-offs of each approach?

13. A colleague argues that integration testing (running the full program with test data) is sufficient and unit testing is unnecessary for COBOL. Provide two specific counter-arguments.

14. What is the difference between a stub and a mock in the context of COBOL testing? Give an example of when you would use each.

15. You have been asked to add unit tests to a 5,000-line COBOL program that has never been tested. Where do you start? Describe your prioritization strategy.

True/False

16. COBOL-Check requires Enterprise COBOL and cannot be used with GnuCOBOL. (True/False)

17. In TDD, you write the test after writing the code to verify it works correctly. (True/False)

18. 100% code coverage guarantees that a program is bug-free. (True/False)

19. A regression test suite should be run before every code promotion to production. (True/False)

20. Custom test harness programs in COBOL can set a non-zero RETURN-CODE to signal test failure to JCL. (True/False)


Answer key available in Appendix G.