ITB2016 - Integration testing in a modern world

Preview:

Citation preview

INTEGRATION TESTING IN A

MODERN WORLD

WHAT THIS TALK ISN'T!

> Framework Agnostic> A strict TDD regiment> How to do Unit testing

WHAT THIS TALK IS!

> Practical Testing> Ways to test against the Database

> An awesome new way to assert against your responses

OTHER SESSION RIGHT NOW

> Web Applications Can Control The WorldBox Room

WHO AM I?

ERIC PETERSON

> ! Utah

> " O.C. Tanner

> # 1 wife, 1 kid

SO YOU WANT TO START TESTING....!

UNIT TESTING

Works really well on individual components.it('calculates the square root', function() { var CUT = new Calculator(); expect(CUT.sqrt(25)).toBe(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!');});

!

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!');});

!

Before we go any further...

PROS AND CONS

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

CONS

> Slow> Doesn't really help you do TDD

> Really slow> Needs a testing database of some kind

> Did I mention slow?

IN REALITY?

DEMOTHE APP

DEMOA SIMPLE INTEGRATION TEST

PROBLEM

Running the test multiple times fails or creates multiple database records

DEMOA TESTING DATABASE

PROBLEM

If we want to use database transactions, we can only make one request

Also, the tests are getting kind of messy

INTEGRATEDHTTPS://GITHUB.COM/ELPETE/INTEGRATED

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

WHAT IS INTEGRATED?

it('renders the welcome view', function() { this.visit('/') .see('Greetings!');});

!

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!');});

!

DEMOINTEGRATED

OTHER SESSIONS AT DEV.OBJECTIVE()

CFML Sessions for DummiesWednesday

3:00 PM to 4:00 PM

Live Testing a Legacy AppThursday

1:45 PM to 2:45 PM

THANK YOU!!

elpete

@_elpete

! dev.elpete.com

Recommended