mad computer science: testing cobol with rspec

19
Mad Computer Science Testing COBOL With RSpec Guy Royse [email protected] @guyroyse

Upload: guy-royse

Post on 20-Jun-2015

498 views

Category:

Technology


1 download

DESCRIPTION

Really? COBOL? Yes, really. There are lots of enterprisey things that just aren't test-driven because of a lack of tooling. COBOL is one of them and it misses out on all the benefits of TDD. But it doesn't have to. In this session I will show how I used RSpec to test-drive MicroFocus COBOL on Windows and demo it with a simple kata. In the process you'll learn a smattering of COBOL and how to apply the same basic technique to test-drive other difficult to test technologies.

TRANSCRIPT

Page 1: Mad Computer Science: Testing COBOL with RSpec

Mad Computer ScienceTesting COBOL With RSpec

Guy [email protected]

@guyroyse

Page 2: Mad Computer Science: Testing COBOL with RSpec

About Me

2

Guy RoyseDevelopment Competency LeadApplication Development Center

Likes TDD, Pairing, Polyglot Programming, Piña Coladas, Walks in the Rain

Dislikes Coding Alone, Complexity, Being Confused for Hagrid

Page 3: Mad Computer Science: Testing COBOL with RSpec

3

COBOLJavaRubyTDD

RSpec

Page 4: Mad Computer Science: Testing COBOL with RSpec

4

Test COBOL

Page 5: Mad Computer Science: Testing COBOL with RSpec

5

About COBOL

Page 6: Mad Computer Science: Testing COBOL with RSpec

6

CompletelyObsoleteBusinessOrientedLanguage

Page 7: Mad Computer Science: Testing COBOL with RSpec

7

** No affiliation with GEICO is intended or implied. All rights reserved. Look both ways before crossing the street. Vote early and vote often.

**

Page 8: Mad Computer Science: Testing COBOL with RSpec

8

"COBOL has almost no fervent enthusiasts. As a programming tool, it has

roughly the sex appeal of a wrench."

Charles Petzold

Page 9: Mad Computer Science: Testing COBOL with RSpec

9

Page 10: Mad Computer Science: Testing COBOL with RSpec

A Simple Application

The Data The Code

10

PhoneValidator

AddressValidator

ContactValidatorContact

AddressPhone

Page 11: Mad Computer Science: Testing COBOL with RSpec

Java Data Implementation

11

public class Contact { private String name; private Phone home; private Phone cell; private Address address;

public String getName() { return name }; public void setName(String name) { this.name = name; }

/* etc. */}

Page 12: Mad Computer Science: Testing COBOL with RSpec

COBOL Data Implementation

12

01 CONTACT. 05 NAME PIC X(30). 05 HOME-PHONE. 10 HOME-AREA-CODE PIC 9(3). 10 HOME-EXCHANGE PIC 9(3). 10 HOME-PHONE-NUMBER PIC 9(4). 05 CELL-PHONE. 10 CELL-AREA-CODE PIC 9(3). 10 CELL-EXCHANGE PIC 9(3). 10 CELL-PHONE-NUMBER PIC 9(4). 05 ADDRESS. 10 STREET PIC X(30). 10 CITY PIC X(20). 10 STATE PIC X(2). 10 ZIP-CODE PIC X(5).

Page 13: Mad Computer Science: Testing COBOL with RSpec

Java Code Implementation

13

public class ContactValidator { private PhoneValidator phoneValidator; private AddressValidator addressValidator;

public void validate(Contact contact) { validateName(contact.getName); phoneValidator.validate(contact.getHome()); phoneValidator.validate(contact.getCell()); addressValidator.validate(contact.getAddress()); }

private void validateName(String name) { /* validates name */ }

}

Page 14: Mad Computer Science: Testing COBOL with RSpec

COBOL Code Implementation

14

IDENTIFICATION DIVISION. PROGRAM-ID. CONTACT-VALIDATOR.

PROCEDURE DIVISION USING CONTACT.

MAIN. CALL PHONE-VALIDATOR USING HOME-PHONE. CALL PHONE-VALIDATOR USING CELL-PHONE. CALL ADDRESS-VALIDATOR USING ADDRESS. PERFORM VALIDATE-NAME. GOBACK

VALIDATE-NAME.* VALIDATE NAME

Page 15: Mad Computer Science: Testing COBOL with RSpec

15

Page 16: Mad Computer Science: Testing COBOL with RSpec

16

COBOL is Just as Testable as Java

Page 17: Mad Computer Science: Testing COBOL with RSpec

COBOLRuby

Eternity

17

contactspec.rb

ETERNITY.CBL

CONTACT.CBL

command.txt

input.txt

output.txt

eternity.rb

Page 18: Mad Computer Science: Testing COBOL with RSpec

18

Demo!

Page 19: Mad Computer Science: Testing COBOL with RSpec

Image Credits

19

http://www.flickr.com/photos/justin_case/1525042316http://www.flickr.com/photos/cbmd/2475626473

http://www.flickr.com/photos/kc-bike/2398970429http://www.flickr.com/photos/7603557@N08/454618030

http://www.flickr.com/photos/pennuja/5386712834http://www.flickr.com/photos/blackeycove/3997170938