Integration Testing in a Modern World

Integration Testing in a Modern World

An introduction to integration testing, testing against databases, and Integrated, a streamlined integration testing library for CFML.

Used in conjunction with https://github.com/elpete/integrated-workshop

Cbddee54e0016667b9bcb0fdec4ab21e?s=128

Eric Peterson

June 14, 2016
Tweet

Transcript

  1. INTEGRATION TESTING IN A MODERN WORLD

  2. WHAT THIS TALK ISN'T ! > Framework Agnostic > A

    strict TDD regiment > How to do Unit testing
  3. WHAT THIS TALK IS ! > Practical Testing > Ways

    to test against the Database > An awesome new way to assert against your responses
  4. OTHER SESSION RIGHT NOW > Web Applications Can Control The

    World Box Room
  5. WHO AM I? ERIC PETERSON > ! Utah > "

    O.C. Tanner > # 1 wife, 1 kid
  6. SO YOU WANT TO START TESTING.... !

  7. UNIT TESTING

  8. Works really well on individual components. it('calculates the square root',

    function() { var CUT = new Calculator(); expect(CUT.sqrt(25)).toBe(5); }); !
  9. ...not as well when you have collaborator components. it('renders the

    welcome view', function() { var CUT = getMockBox() .createMock('handlers.Welcome'); var mockService = getMockBox().createMock('models.WelcomeService'); mockService.$('getGreeting', 'Greetings!'); CUT.mockProperty(propertyName = 'service', mock = mockService); var event = CUT.index(); expect(event.getValue('greeting')).toBe('Greetings!'); }); !
  10. Here's the same test as an Integration test. it('renders the

    welcome view', function() { var event = execute(event = 'Welcome.index', renderResults = true); expect(event.getValue('greeting')).toBe('Greetings!'); }); !
  11. Before we go any further... PROS AND CONS

  12. PROS > Easier to get started with > Makes sure

    that your application is wired together correctly > Avoids Mocks (which can be really confusing) > High level tests make refactoring easier
  13. CONS > Slow > Doesn't really help you do TDD

    > Really slow > Needs a testing database of some kind > Did I mention slow?
  14. IN REALITY?

  15. DEMO THE APP

  16. DEMO A SIMPLE INTEGRATION TEST

  17. PROBLEM Running the test multiple times fails or creates multiple

    database records
  18. DEMO A TESTING DATABASE

  19. PROBLEM If we want to use database transactions, we can

    only make one request Also, the tests are getting kind of messy
  20. INTEGRATED HTTPS://GITHUB.COM/ELPETE/INTEGRATED

  21. WHAT IS INTEGRATED? > Built on ColdBox (4.2+) and TestBox

    (2.3+) > Augments the built-in ColdBox Integration test > Easy database transactions across multiple requests > jQuery-style page assertions
  22. WHAT IS INTEGRATED? it('renders the welcome view', function() { this.visit('/')

    .see('Greetings!'); }); !
  23. WHAT IS INTEGRATED? it('renders the welcome view', function() { this.visit('/dashboard')

    .seePageIs('/login') .click('Register') .type('John', 'username') .type('john@example.com', 'email') .type('mY@wes0meP@ssw0rd', 'password') .press('Submit') .seePageIs('/dashboard') .see('Welcome to the team, John!'); }); !
  24. DEMO INTEGRATED

  25. OTHER SESSIONS AT DEV.OBJECTIVE() CFML Sessions for Dummies Wednesday 3:00

    PM to 4:00 PM Live Testing a Legacy App Thursday 1:45 PM to 2:45 PM
  26. THANK YOU!! elpete @_elpete ! dev.elpete.com