O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Mad Computer Science: Testing COBOL with RSpec

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.

  • Seja o primeiro a comentar

  • Seja a primeira pessoa a gostar disto

Mad Computer Science: Testing COBOL with RSpec

  1. 1. Mad Computer Science Testing COBOL With RSpec Guy Royse royseg@nationwide.com @guyroyse
  2. 2. About Me Guy Royse Development Competency Lead Application Development Center LikesTDD, Pairing, Polyglot Programming, Piña Coladas, Walks in the Rain Dislikes Coding Alone, Complexity, Being Confused for Hagrid 2
  3. 3. COBOL Java Ruby TDD RSpec 3
  4. 4. 4
  5. 5. About COBOL 5
  6. 6. Completely Obsolete Business Oriented Language 6
  7. 7. ** ** No affiliation with GEICO is intended or implied. All rights reserved. Look both ways before crossing the street. Vote early and vote often. 7
  8. 8. 8
  9. 9. 9
  10. 10. A Simple Application The Data The Code Contact Validator Contact Phone Address Phone Validator Address Validator 10
  11. 11. Java Data Implementation 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. */ } 11
  12. 12. COBOL Data Implementation 01 CONTACT. 05 NAME 05 HOME-PHONE. 10 HOME-AREA-CODE 10 HOME-EXCHANGE 10 HOME-PHONE-NUMBER 05 CELL-PHONE. 10 CELL-AREA-CODE 10 CELL-EXCHANGE 10 CELL-PHONE-NUMBER 05 ADDRESS. 10 STREET 10 CITY 10 STATE 10 ZIP-CODE PIC X(30). PIC 9(3). PIC 9(3). PIC 9(4). PIC 9(3). PIC 9(3). PIC 9(4). PIC PIC PIC PIC X(30). X(20). X(2). X(5). 12
  13. 13. Java Code Implementation public class ContactValidator { private PhoneValidatorphoneValidator; private AddressValidatoraddressValidator; 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 */ } } 13
  14. 14. COBOL Code Implementation 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 14
  15. 15. 15
  16. 16. 16
  17. 17. Eternity Ruby COBOL command.txt input.txt contact spec.rb ETERNITY .CBL eternity.rb CONTACT .CBL output.txt 17
  18. 18. 18
  19. 19. Image Credits http://www.flickr.com/photos/justin_case/1525042316 http://www.flickr.com/photos/cbmd/2475626473 http://www.flickr.com/photos/kc-bike/2398970429 http://www.flickr.com/photos/7603557@N08/454618030 http://www.flickr.com/photos/pennuja/5386712834 http://www.flickr.com/photos/blackeycove/3997170938 19

×