tdd final submission

26
Project AutoMock and Jasmine: Testing Auto- magically!! The inside story of how we stopped breaking our own code at Adobe…

Upload: harshit040591

Post on 18-Aug-2015

22 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Tdd final submission

Project AutoMock and Jasmine: Testing Auto-magically!!

The inside story of how we stopped breaking our own code at Adobe…

Page 2: Tdd final submission

About Me

• Neha Singhal – Developer at Adobe. – Active in web development and UI for the past 2.5 years. – Likes solving interesting problems involving UI and UX– On a personal front she is an avid dancer, loves to travel and is a big fan of

animated movies.

Page 3: Tdd final submission

3

So how did it all begin??

Page 4: Tdd final submission

4

Our Journey @ Adobe

Version 2.0 Version 3.0

Bugs by QA Team 156 15 (so far)

Regression Bugs 52 0 (so far)

Integration Bugs > 50 < 5

Bug fixing (in days) ~14 ~3

Dev validation before handoff 5 days 4 hours

Dead code (lines) ~1470 < 50

Impressed? This isn’t even the best part!

Page 5: Tdd final submission

Still think testing isn’t important??

<video>

Page 6: Tdd final submission

TDD: The Basics

• Development Philosophy• Execution steps :

– Add a test – Watch it fail (Cry silently)– Write Code– Watch It Pass– Celebrate– Repeat!

TEST

CODE

DEPLOY

INTEGRATE

RELEASE

Page 7: Tdd final submission

Jasmine is.. A Beautiful Disney Princess ?

Page 8: Tdd final submission

Just Kidding..

Jasmine is..

• Javascript Testing Framework• Independent of browsers, DOM • Supports multiple Javascript frameworks• Headless running out of the box• Clean Syntax

Page 9: Tdd final submission

9

Our first baby steps...

Page 10: Tdd final submission

Let’s meet our mighty heroes...

• Suite : to describe a section of your code

• Specs: it creates a new spec

• Expectations : what you expect the code block to do

Page 11: Tdd final submission

Let’s meet our mighty heroes...

• Matchers : utility functions– toEqual– toMatch– toBeTruthy– And lots more to list here..

Page 12: Tdd final submission

12

With great power…comes an easy way to

write a test case...

Page 13: Tdd final submission

With Great Power…

We can even create one of our own !!

Page 14: Tdd final submission

14

Before we knew it… We were all grown up…

Page 15: Tdd final submission

Unpredictable Minions of Jasmine (Async callbacks)

• You never know when and what they are going to do.. (just like async callbacks)

• Jasmine now supports async methods through done leaving it up to the developer to control the execution flow.

• Setup– Jasmine lets you setup tests by running code before all/each test

• Teardown– You can also run cleanup after all tests or after each test

Page 16: Tdd final submission

Let’s pull the rabbit out of the hat..• What if we told you there was a way to

automatically mock your entire backend without having to touch the source code or add specific test code…– Feels like magic doesn’t it?......Wait for it..

Page 17: Tdd final submission

Let’s pull the rabbit out of the hat..

Introducing…

“Project AutoMock”!!

Page 18: Tdd final submission

Project AutoMock

Project AutoMock is an original project we are developing for mocking the entire backend

Page 19: Tdd final submission

Tired??

• Tired of waiting for the backend API to be ready?• Tired of waiting for API calls to return in your test cases?• Tired of test data ruining your DB?• Tired of the long, slow process of stubbing each and

every API call?

Yeah. So were we…Let me tell you what we did about it…

Page 20: Tdd final submission

20

Why Tell You… When I Can Show You…

Page 21: Tdd final submission

What it does

• Automatically captures AJAX requests and responses

• Integrates well with testing frameworks like Jasmine

• Automatically creates API stubs for testing using the real captured data

Page 22: Tdd final submission

The Best Part…

• Integration Guide:– For React.js

– For Angular.js

– For Backbone.js

Spot The Difference

Page 23: Tdd final submission

What we have achieved so far

• No manual effort at all– Mocking API calls is now essentially an automatic process– Little to no developer intervention required to create the API stubs

• Built for speed– Test cases run much faster now that no network requests are made– The testing process is speed up considerably

• Test cases for AJAX calls no longer require async test cases. It’s instantaneous.

• No more messy code required to test each API call

Page 24: Tdd final submission

24

It’s not the end… It’s the beginning of a

new era…

Page 25: Tdd final submission

What good are questions...

…without answers!!

Page 26: Tdd final submission

Thank You!!@Neha_Singhal