Redefining the unit
Felix Holzäpfel-Stein & Michael Calvert
© 2020 ThoughtWorks
Mainframes and Cobol
The client context
© 2020 ThoughtWorks
Potentially shippable
increment
every 2 weeks?
Quarterly releases
with
6 weeks of
manual testing
Large insurance
with
many critical
mainframe systems
Transformation
towards
continuous and agile
software development
practices
---------------------------- XConf 2020 ----------------------------
Agenda =>
0 Context
1 Finding a testable unit
2 Testing a unit
3 Conclusions
X to exit
3270 ---------------------------------------------------------------
© 2020 ThoughtWorks
June 2020
SU MO TU WE TH FR SA
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
© 2020 ThoughtWorks
…Modules
…10k lines
of code
…Maybe
even 30k...
© 2020 ThoughtWorks
…sub
programs
…up to 3k
lines of code
© 2020 ThoughtWorks
…sections
…isolation
not possible
---------------------------- XConf 2020 ----------------------------
Agenda =>
0 Context
1 Finding a testable unit
2 Testing a unit
3 Conclusions
X to exit
3270 ---------------------------------------------------------------
© 2020 ThoughtWorks
June 2020
SU MO TU WE TH FR SA
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Some things beforehand
© 2020 ThoughtWorks
No
Cobol DSL Grammar &
Parsing
NoMAINFRAME
Running stuff on the Mainframe is expensive
© 2020 ThoughtWorks
An example module
IDENTIFICATION DIVISION.
PROGRAM-ID. MY-PROGRAM.
© 2020 ThoughtWorks
Hello, XConf 2020
Enter a number:
4
Enter another number:
13
The Result is :
000000000000017
Program metadata
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A-NAME PIC A(30).
01 AN-ID PIC 9(5) VALUE '12345'.
01 A-NUM PIC 9(12) VALUE '0'.
01 OTHER-NUM PIC 9(12) VALUE '0'.
01 RESULT PIC 9(15) VALUE '0'.
PROCEDURE DIVISION.
MOVE 'XConf 2020' TO A-NAME.
DISPLAY "Hello, "A-NAME.
DISPLAY "Enter a number:"
ACCEPT A-NUM.
DISPLAY "Enter another number:"
ACCEPT OTHER-NUM.
PERFORM ADD-TWO-INTS.
ADD-TWO-INTS SECTION.
ADD A-NUM OTHER-NUM GIVING RESULT.
DISPLAY "The Result is : "RESULT
STOP RUN.
11
Variable definitions
2
2
Like a main()
function
Like calling a
function
Like defining a
function
3
4
5
3
4
5
Building a test driver
ADD-TWO-INTS SECTION.
ADD A-NUM OTHER-NUM GIVING RESULT.
DISPLAY "The Result is : "RESULT
© 2020 ThoughtWorks
ADD-TWO-INTS SECTION.
ADD A-NUM OTHER-NUM GIVING RESULT.
DISPLAY "The Result is : "RESULT
ADD-TWO-INTS SECTION.
ADD A-NUM OTHER-NUM GIVING RESULT.
DISPLAY "The Result is : "RESULT
ADD-TWO-INTS SECTION.
ADD A-NUM OTHER-NUM GIVING RESULT.
DISPLAY "The Result is : "RESULT
WORKING-STORAGE SECTION.
01 A-NUM PIC 9(12) VALUE '0'.
LINKAGE SECTION.
01 OTHER-NUM PIC 9(12).
PROGRAM-ID. ANOTHER-PROGRAM.
WORKING-STORAGE SECTION.
01 A-NUM EXTERNAL PIC 9(12).
Module
Section
Traversing the syntax tree
© 2020 ThoughtWorks
Sub program
Sub program
Section
Declaration here
Declaration here
Declaration not
really here
User Research
© 2020 ThoughtWorks
Error messages
© 2020 ThoughtWorks Images from: https://www.techrepublic.com/pictures/weird-error-messages/14/
Mocking
© 2020 ThoughtWorks
ADD-TWO-INTS SECTION.
ADD A-NUM OTHER-NUM GIVING RESULT.
DISPLAY "The Result is : "RESULT
CALL 'CLEAN-UP' USING A-NUM, OTHER-NUM.
PERFORM PREPARE-SOMETHING.
Mocking
© 2020 ThoughtWorks
MOCK SECTION PREPARE-SOMETHING
<cobol>
MOVE 0 TO A-NUM.
</cobol>
END-MOCK
Fast feedback loop?
© 2020 ThoughtWorks
We still need to parse the
entire Cobol program...
© 2020 ThoughtWorks
What is a mainframe?
© 2020 ThoughtWorks
Compatibility with
older systems
Punch cards.
© 2020 ThoughtWorks
---------------------------- XConf 2020 ----------------------------
Agenda =>
0 Context
1 Finding a testable unit
2 Testing a unit
3 Conclusions
X to exit
3270 ---------------------------------------------------------------
© 2020 ThoughtWorks
June 2020
SU MO TU WE TH FR SA
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Conclusions
© 2020 ThoughtWorks
What we learnt in this wrestling match with
technology
Build
Collect user
feedback
Learn from
feedback
Our assumption of what a COBOL unit
test should be or look like was not what
our users needed or wanted
● Build an increment with small changes
● Actively test it in a user workshop
● Learn from and adapt to user feedback
User centric approach
© 2020 ThoughtWorks
How accurate do we
really need to be?
© 2020 ThoughtWorks
“Ambiguity? Never heard of it.”
- IBM Cobol Compiler*, 2019
© 2020 ThoughtWorks
*Not a real quote. The IBM Compiler never actually spoke these words. We’re pretty sure it was
thinking it though. Along with other evil things.
“Please, do not fix this [compiler]
issue. This is a programming error
that the IBM compiler does not catch
currently”
- Client Testmanager
© 2020 ThoughtWorks
How accurate do we
really need to be?
© 2020 ThoughtWorks
Actually not 100%
accurate
© 2020 ThoughtWorks
Fast feedback but not too expensive
© 2020 ThoughtWorks
Felix Holzäpfel-Stein &
Michael Calvert
Thank you
© 2020 ThoughtWorks
Continue the
conversation on Slack
© 2020 ThoughtWorks
XConfEurope2020
xconfeurope2020.slack.com
#talk1-redefining-the-unit
#XConfOnline

Redefining the unit

  • 1.
    Redefining the unit FelixHolzäpfel-Stein & Michael Calvert © 2020 ThoughtWorks
  • 2.
  • 3.
    The client context ©2020 ThoughtWorks Potentially shippable increment every 2 weeks? Quarterly releases with 6 weeks of manual testing Large insurance with many critical mainframe systems Transformation towards continuous and agile software development practices
  • 4.
    ---------------------------- XConf 2020---------------------------- Agenda => 0 Context 1 Finding a testable unit 2 Testing a unit 3 Conclusions X to exit 3270 --------------------------------------------------------------- © 2020 ThoughtWorks June 2020 SU MO TU WE TH FR SA 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
  • 5.
    © 2020 ThoughtWorks …Modules …10klines of code …Maybe even 30k...
  • 6.
  • 7.
  • 8.
    ---------------------------- XConf 2020---------------------------- Agenda => 0 Context 1 Finding a testable unit 2 Testing a unit 3 Conclusions X to exit 3270 --------------------------------------------------------------- © 2020 ThoughtWorks June 2020 SU MO TU WE TH FR SA 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
  • 9.
    Some things beforehand ©2020 ThoughtWorks No Cobol DSL Grammar & Parsing NoMAINFRAME
  • 10.
    Running stuff onthe Mainframe is expensive © 2020 ThoughtWorks
  • 11.
    An example module IDENTIFICATIONDIVISION. PROGRAM-ID. MY-PROGRAM. © 2020 ThoughtWorks Hello, XConf 2020 Enter a number: 4 Enter another number: 13 The Result is : 000000000000017 Program metadata DATA DIVISION. WORKING-STORAGE SECTION. 01 A-NAME PIC A(30). 01 AN-ID PIC 9(5) VALUE '12345'. 01 A-NUM PIC 9(12) VALUE '0'. 01 OTHER-NUM PIC 9(12) VALUE '0'. 01 RESULT PIC 9(15) VALUE '0'. PROCEDURE DIVISION. MOVE 'XConf 2020' TO A-NAME. DISPLAY "Hello, "A-NAME. DISPLAY "Enter a number:" ACCEPT A-NUM. DISPLAY "Enter another number:" ACCEPT OTHER-NUM. PERFORM ADD-TWO-INTS. ADD-TWO-INTS SECTION. ADD A-NUM OTHER-NUM GIVING RESULT. DISPLAY "The Result is : "RESULT STOP RUN. 11 Variable definitions 2 2 Like a main() function Like calling a function Like defining a function 3 4 5 3 4 5
  • 12.
    Building a testdriver ADD-TWO-INTS SECTION. ADD A-NUM OTHER-NUM GIVING RESULT. DISPLAY "The Result is : "RESULT © 2020 ThoughtWorks ADD-TWO-INTS SECTION. ADD A-NUM OTHER-NUM GIVING RESULT. DISPLAY "The Result is : "RESULT ADD-TWO-INTS SECTION. ADD A-NUM OTHER-NUM GIVING RESULT. DISPLAY "The Result is : "RESULT ADD-TWO-INTS SECTION. ADD A-NUM OTHER-NUM GIVING RESULT. DISPLAY "The Result is : "RESULT WORKING-STORAGE SECTION. 01 A-NUM PIC 9(12) VALUE '0'. LINKAGE SECTION. 01 OTHER-NUM PIC 9(12). PROGRAM-ID. ANOTHER-PROGRAM. WORKING-STORAGE SECTION. 01 A-NUM EXTERNAL PIC 9(12).
  • 13.
    Module Section Traversing the syntaxtree © 2020 ThoughtWorks Sub program Sub program Section Declaration here Declaration here Declaration not really here
  • 14.
  • 15.
    Error messages © 2020ThoughtWorks Images from: https://www.techrepublic.com/pictures/weird-error-messages/14/
  • 16.
    Mocking © 2020 ThoughtWorks ADD-TWO-INTSSECTION. ADD A-NUM OTHER-NUM GIVING RESULT. DISPLAY "The Result is : "RESULT CALL 'CLEAN-UP' USING A-NUM, OTHER-NUM. PERFORM PREPARE-SOMETHING.
  • 17.
    Mocking © 2020 ThoughtWorks MOCKSECTION PREPARE-SOMETHING <cobol> MOVE 0 TO A-NUM. </cobol> END-MOCK
  • 18.
    Fast feedback loop? ©2020 ThoughtWorks
  • 19.
    We still needto parse the entire Cobol program... © 2020 ThoughtWorks
  • 20.
    What is amainframe? © 2020 ThoughtWorks Compatibility with older systems
  • 21.
  • 22.
    ---------------------------- XConf 2020---------------------------- Agenda => 0 Context 1 Finding a testable unit 2 Testing a unit 3 Conclusions X to exit 3270 --------------------------------------------------------------- © 2020 ThoughtWorks June 2020 SU MO TU WE TH FR SA 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
  • 23.
    Conclusions © 2020 ThoughtWorks Whatwe learnt in this wrestling match with technology
  • 24.
    Build Collect user feedback Learn from feedback Ourassumption of what a COBOL unit test should be or look like was not what our users needed or wanted ● Build an increment with small changes ● Actively test it in a user workshop ● Learn from and adapt to user feedback User centric approach © 2020 ThoughtWorks
  • 25.
    How accurate dowe really need to be? © 2020 ThoughtWorks
  • 26.
    “Ambiguity? Never heardof it.” - IBM Cobol Compiler*, 2019 © 2020 ThoughtWorks *Not a real quote. The IBM Compiler never actually spoke these words. We’re pretty sure it was thinking it though. Along with other evil things.
  • 27.
    “Please, do notfix this [compiler] issue. This is a programming error that the IBM compiler does not catch currently” - Client Testmanager © 2020 ThoughtWorks
  • 28.
    How accurate dowe really need to be? © 2020 ThoughtWorks
  • 29.
  • 30.
    Fast feedback butnot too expensive © 2020 ThoughtWorks
  • 31.
    Felix Holzäpfel-Stein & MichaelCalvert Thank you © 2020 ThoughtWorks
  • 32.
    Continue the conversation onSlack © 2020 ThoughtWorks XConfEurope2020 xconfeurope2020.slack.com #talk1-redefining-the-unit #XConfOnline