Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

Eric Peterson

June 14, 2016
Tweet

More Decks by Eric Peterson

Other Decks in Programming

Transcript

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

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

    to test against the Database > An awesome new way to assert against your responses
  3. WHO AM I? ERIC PETERSON > ! Utah > "

    O.C. Tanner > # 1 wife, 1 kid
  4. Works really well on individual components. it('calculates the square root',

    function() { var CUT = new Calculator(); expect(CUT.sqrt(25)).toBe(5); }); !
  5. ...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!'); }); !
  6. 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!'); }); !
  7. 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
  8. CONS > Slow > Doesn't really help you do TDD

    > Really slow > Needs a testing database of some kind > Did I mention slow?
  9. PROBLEM If we want to use database transactions, we can

    only make one request Also, the tests are getting kind of messy
  10. 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
  11. WHAT IS INTEGRATED? it('renders the welcome view', function() { this.visit('/dashboard')

    .seePageIs('/login') .click('Register') .type('John', 'username') .type('[email protected]', 'email') .type('mY@wes0meP@ssw0rd', 'password') .press('Submit') .seePageIs('/dashboard') .see('Welcome to the team, John!'); }); !
  12. 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