SlideShare a Scribd company logo
describe('UnitTes.ng', 
func.on(){ 
it('works 
with 
AngularJS'… 
} 
Jesse 
Liberty 
Master 
Consultant 
Falafel 
SoFware 
jesse@falafel.com 
@jesseliberty
What We Will Cover 
• Why 
bother? 
• Why 
Aren't 
We 
Doing 
It? 
• Wri.ng 
specs 
• Matchers 
• Spies
Getting the terms right 
§ Unit Test 
§ Test Driven Development (TDD) 
o Test First Development 
§ Behavior Driven Development (BDD)
Am I In The Right Presenta7on? 
• I 
assume… 
• Comfort 
with 
Angular 
Fundamentals 
• No 
prior 
experience 
with 
unit 
tes.ng
Ques7ons 
If 
you 
get 
lost 
it 
will 
be 
hard 
to 
catch 
up 
so 
please, 
please 
ask 
ques.ons 
Copyright 
© 
2003-­‐2014 
Falafel 
SoFware 
Inc. 
5 
Q&A 
at 
the 
end
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Getting Started 
§ What you already need to know 
o Javascript 
o Angular 
§ What hardware you need 
§ What software you need 
§ Where to get everything 
o Getting Jasmine 
o Finding documentation 
o Finding Help
jasmine.github.io
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Red, Green, Rafactor 
§ Red – Your Test Should Fail 
§ Green – Make Your Test Pass 
§ Refactor – Clean up your code without breaking your test
Red, Green, Rafactor 
§ Red – Your Test Should Fail 
§ Green – Make Your Test Work 
§ Refactor – Clean up your code without breaking your test 
Lather 
Rinse 
Repeat
Three Laws 
1. You may not write production code until 
you have a failing test 
2. You may not write more of a unit test than 
is sufficient to fail 
3. You may not write more production code 
than is sufficient to pass
The Prime Directive 
§ Your test code should be as good and well maintained as your 
production code. 
o Succinct 
o Clear 
o Simple 
§ However, do not worry about efficiency in test code
Test One Concept In Each Test 
§ Pass/Fail should immediately convey what was tested and the result
F.I.R.S.T. 
§ Fast 
§ Independent 
§ Repeatable 
§ Self-validating (boolean output) 
§ Timely
SEE: 
Setup 
Execute 
Check Expectations
Wri7ng Your First Spec
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Demo
Measuring your step size
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Matchers
Matchers 
§ toBe 
§ toEqual 
§ toBeTruthy 
§ toBeNull, toBeUndefined, toBeNaN 
§ toContain 
§ toMatch 
§ toBeLessThan 
§ etc.
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Demo
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Demo
Custom Matchers 
• How 
would 
we 
test 
that 
an 
expense 
item 
is 
"reasonable?" 
• Problem 
#1 
– 
We'd 
like 
to 
use 
"ToBeReasonable" 
• Problem 
#2 
– 
How 
will 
the 
compare 
pick 
out 
the 
amount 
as 
the 
value 
to 
test? 
new 
ExpenseItem( 
'taxi', 
'Taxi 
to 
airport', 
89.50);
Custom Matchers
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Demo
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Making An Expense Item 
§ Delete expense.js 
§ Add new parameters to ExpenseItem
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Requirement: 
Persist 
expenses 
and 
report 
number 
that 
were 
persisted
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Demo
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014
Ques7ons? 
Contact 
me: 
jesse@falafel.com 
@jesseliberty
Contact Me 
• Jesse 
Liberty 
• Falafel 
SoFware 
• jesse@falafel.com 
• @jesseliberty
Ad

Recommended

The Apex Ten Commandments
The Apex Ten Commandments
Salesforce Developers
 
Advanced unit testing – real life examples and mistakes
Advanced unit testing – real life examples and mistakes
Milan Vukoje
 
Real Life Unit Testing
Real Life Unit Testing
Dror Helper
 
The Rowe Flow
The Rowe Flow
askdub
 
Developer Testing
Developer Testing
Chris Wallace
 
Rules of UI prototyping
Rules of UI prototyping
Alex Kouznetsov
 
Tdd!
Tdd!
Steven Nunez
 
Automate Debugging with git bisect
Automate Debugging with git bisect
Camille Bell
 
Helping Programmers Write Better Tests
Helping Programmers Write Better Tests
Geoffrey Dunn
 
Agile testingandautomation
Agile testingandautomation
jeisner
 
Learn Unit Testing and Improve Sexual Performance
Learn Unit Testing and Improve Sexual Performance
Bill Shelton
 
Developer Night - Opticon18
Developer Night - Opticon18
Optimizely
 
U certify earlybird sale
U certify earlybird sale
jasminesmith2111
 
Grading the Quality of Selenium Tests
Grading the Quality of Selenium Tests
Marcus Merrell
 
Zen And the Art of Test Maintenance Presentation
Zen And the Art of Test Maintenance Presentation
Gil Zilberfeld
 
Zen and the art of Test Maintenance - #TestIL Meetup Tel Aviv
Zen and the art of Test Maintenance - #TestIL Meetup Tel Aviv
Gil Zilberfeld
 
Zen and the Art of Test Maintenance
Zen and the Art of Test Maintenance
Gil Zilberfeld
 
Patterns in Testing and a claim - iCheckWebsite
Patterns in Testing and a claim - iCheckWebsite
Anand Ramdeo
 
Dirty tests and How To Clean Them
Dirty tests and How To Clean Them
Gil Zilberfeld
 
Unit testing for Grown-ups
Unit testing for Grown-ups
Gil Zilberfeld
 
Living with acceptance tests: Beyond Write-Once (XP NYC)
Living with acceptance tests: Beyond Write-Once (XP NYC)
Daniel Wellman
 
Refactoring legacy code
Refactoring legacy code
Pablo Neves Machado
 
It's the Little Things: Creating a Delightful WordPress Experience for Your C...
It's the Little Things: Creating a Delightful WordPress Experience for Your C...
Big Sea
 
ATDD with Pepino
ATDD with Pepino
Byron Sommardahl
 
Agile Network India | Be Customer Centric with Test First Development | Mamat...
Agile Network India | Be Customer Centric with Test First Development | Mamat...
AgileNetwork
 
4 TSPN_Apex 10 Commandments
4 TSPN_Apex 10 Commandments
TerraSky
 
Maintaining Retainers as a WordPress Developer
Maintaining Retainers as a WordPress Developer
DevinVinson
 
Top 10 die besten 3D Camcorder in 2018
Top 10 die besten 3D Camcorder in 2018
fudesavylac
 
Angularjs Test Driven Development (TDD)
Angularjs Test Driven Development (TDD)
Anis Bouhachem Djer
 
Testing: ¿what, how, why?
Testing: ¿what, how, why?
David Rodenas
 

More Related Content

What's hot (20)

Helping Programmers Write Better Tests
Helping Programmers Write Better Tests
Geoffrey Dunn
 
Agile testingandautomation
Agile testingandautomation
jeisner
 
Learn Unit Testing and Improve Sexual Performance
Learn Unit Testing and Improve Sexual Performance
Bill Shelton
 
Developer Night - Opticon18
Developer Night - Opticon18
Optimizely
 
U certify earlybird sale
U certify earlybird sale
jasminesmith2111
 
Grading the Quality of Selenium Tests
Grading the Quality of Selenium Tests
Marcus Merrell
 
Zen And the Art of Test Maintenance Presentation
Zen And the Art of Test Maintenance Presentation
Gil Zilberfeld
 
Zen and the art of Test Maintenance - #TestIL Meetup Tel Aviv
Zen and the art of Test Maintenance - #TestIL Meetup Tel Aviv
Gil Zilberfeld
 
Zen and the Art of Test Maintenance
Zen and the Art of Test Maintenance
Gil Zilberfeld
 
Patterns in Testing and a claim - iCheckWebsite
Patterns in Testing and a claim - iCheckWebsite
Anand Ramdeo
 
Dirty tests and How To Clean Them
Dirty tests and How To Clean Them
Gil Zilberfeld
 
Unit testing for Grown-ups
Unit testing for Grown-ups
Gil Zilberfeld
 
Living with acceptance tests: Beyond Write-Once (XP NYC)
Living with acceptance tests: Beyond Write-Once (XP NYC)
Daniel Wellman
 
Refactoring legacy code
Refactoring legacy code
Pablo Neves Machado
 
It's the Little Things: Creating a Delightful WordPress Experience for Your C...
It's the Little Things: Creating a Delightful WordPress Experience for Your C...
Big Sea
 
ATDD with Pepino
ATDD with Pepino
Byron Sommardahl
 
Agile Network India | Be Customer Centric with Test First Development | Mamat...
Agile Network India | Be Customer Centric with Test First Development | Mamat...
AgileNetwork
 
4 TSPN_Apex 10 Commandments
4 TSPN_Apex 10 Commandments
TerraSky
 
Maintaining Retainers as a WordPress Developer
Maintaining Retainers as a WordPress Developer
DevinVinson
 
Top 10 die besten 3D Camcorder in 2018
Top 10 die besten 3D Camcorder in 2018
fudesavylac
 
Helping Programmers Write Better Tests
Helping Programmers Write Better Tests
Geoffrey Dunn
 
Agile testingandautomation
Agile testingandautomation
jeisner
 
Learn Unit Testing and Improve Sexual Performance
Learn Unit Testing and Improve Sexual Performance
Bill Shelton
 
Developer Night - Opticon18
Developer Night - Opticon18
Optimizely
 
Grading the Quality of Selenium Tests
Grading the Quality of Selenium Tests
Marcus Merrell
 
Zen And the Art of Test Maintenance Presentation
Zen And the Art of Test Maintenance Presentation
Gil Zilberfeld
 
Zen and the art of Test Maintenance - #TestIL Meetup Tel Aviv
Zen and the art of Test Maintenance - #TestIL Meetup Tel Aviv
Gil Zilberfeld
 
Zen and the Art of Test Maintenance
Zen and the Art of Test Maintenance
Gil Zilberfeld
 
Patterns in Testing and a claim - iCheckWebsite
Patterns in Testing and a claim - iCheckWebsite
Anand Ramdeo
 
Dirty tests and How To Clean Them
Dirty tests and How To Clean Them
Gil Zilberfeld
 
Unit testing for Grown-ups
Unit testing for Grown-ups
Gil Zilberfeld
 
Living with acceptance tests: Beyond Write-Once (XP NYC)
Living with acceptance tests: Beyond Write-Once (XP NYC)
Daniel Wellman
 
It's the Little Things: Creating a Delightful WordPress Experience for Your C...
It's the Little Things: Creating a Delightful WordPress Experience for Your C...
Big Sea
 
Agile Network India | Be Customer Centric with Test First Development | Mamat...
Agile Network India | Be Customer Centric with Test First Development | Mamat...
AgileNetwork
 
4 TSPN_Apex 10 Commandments
4 TSPN_Apex 10 Commandments
TerraSky
 
Maintaining Retainers as a WordPress Developer
Maintaining Retainers as a WordPress Developer
DevinVinson
 
Top 10 die besten 3D Camcorder in 2018
Top 10 die besten 3D Camcorder in 2018
fudesavylac
 

Similar to Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014 (20)

Angularjs Test Driven Development (TDD)
Angularjs Test Driven Development (TDD)
Anis Bouhachem Djer
 
Testing: ¿what, how, why?
Testing: ¿what, how, why?
David Rodenas
 
Test-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS Applications
FITC
 
How Testability Inspires AngularJS Design / Ran Mizrahi
How Testability Inspires AngularJS Design / Ran Mizrahi
Ran Mizrahi
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introduction
Nir Kaufman
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
Ran Mizrahi
 
Qunit Java script Un
Qunit Java script Un
akanksha arora
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
Ortus Solutions, Corp
 
Unit Testing - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and Hows
atesgoral
 
Testing, Learning and Professionalism — 20171214
Testing, Learning and Professionalism — 20171214
David Rodenas
 
JavaCro'14 - Unit testing in AngularJS – Slaven Tomac
JavaCro'14 - Unit testing in AngularJS – Slaven Tomac
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Unit Testing Front End JavaScript
Unit Testing Front End JavaScript
FITC
 
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API
Gavin Pickin
 
3 WAYS TO TEST YOUR COLDFUSION API -
3 WAYS TO TEST YOUR COLDFUSION API -
Ortus Solutions, Corp
 
Unit testing with Jasmine
Unit testing with Jasmine
simonKenyonShepard
 
Slaven tomac unit testing in angular js
Slaven tomac unit testing in angular js
Slaven Tomac
 
ES3-2020-06 Test Driven Development (TDD)
ES3-2020-06 Test Driven Development (TDD)
David Rodenas
 
Painless Javascript Unit Testing
Painless Javascript Unit Testing
Benjamin Wilson
 
Tests in Javascript using Jasmine and Testacular
Tests in Javascript using Jasmine and Testacular
Paulo Cesar Ortins Brito
 
Testing Strategies for Node.pdf
Testing Strategies for Node.pdf
infowindtech
 
Angularjs Test Driven Development (TDD)
Angularjs Test Driven Development (TDD)
Anis Bouhachem Djer
 
Testing: ¿what, how, why?
Testing: ¿what, how, why?
David Rodenas
 
Test-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS Applications
FITC
 
How Testability Inspires AngularJS Design / Ran Mizrahi
How Testability Inspires AngularJS Design / Ran Mizrahi
Ran Mizrahi
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introduction
Nir Kaufman
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
Ran Mizrahi
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
Ortus Solutions, Corp
 
Unit Testing - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and Hows
atesgoral
 
Testing, Learning and Professionalism — 20171214
Testing, Learning and Professionalism — 20171214
David Rodenas
 
Unit Testing Front End JavaScript
Unit Testing Front End JavaScript
FITC
 
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API
Gavin Pickin
 
3 WAYS TO TEST YOUR COLDFUSION API -
3 WAYS TO TEST YOUR COLDFUSION API -
Ortus Solutions, Corp
 
Slaven tomac unit testing in angular js
Slaven tomac unit testing in angular js
Slaven Tomac
 
ES3-2020-06 Test Driven Development (TDD)
ES3-2020-06 Test Driven Development (TDD)
David Rodenas
 
Painless Javascript Unit Testing
Painless Javascript Unit Testing
Benjamin Wilson
 
Tests in Javascript using Jasmine and Testacular
Tests in Javascript using Jasmine and Testacular
Paulo Cesar Ortins Brito
 
Testing Strategies for Node.pdf
Testing Strategies for Node.pdf
infowindtech
 
Ad

More from FalafelSoftware (13)

Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
FalafelSoftware
 
AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014
AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014
FalafelSoftware
 
DDD with ASP.NET MVC - Steve Smith | FalafelCON 2014
DDD with ASP.NET MVC - Steve Smith | FalafelCON 2014
FalafelSoftware
 
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
FalafelSoftware
 
Solving Mobile Test Automation Challenges with TestComplete - Nick Olivo | Fa...
Solving Mobile Test Automation Challenges with TestComplete - Nick Olivo | Fa...
FalafelSoftware
 
iBeacons for Everyone, from iOS to Android - James Montemagno | FalafelCON 2014
iBeacons for Everyone, from iOS to Android - James Montemagno | FalafelCON 2014
FalafelSoftware
 
XAML Development with Xamarin - Jesse Liberty | FalafelCON 2014
XAML Development with Xamarin - Jesse Liberty | FalafelCON 2014
FalafelSoftware
 
AngularJS and Kendo UI - Jesse Liberty | FalafelCON 2014
AngularJS and Kendo UI - Jesse Liberty | FalafelCON 2014
FalafelSoftware
 
Agile Patterns: Estimation - Stephen Forte | FalafelCON 2014
Agile Patterns: Estimation - Stephen Forte | FalafelCON 2014
FalafelSoftware
 
Mobile ASP.Net Web Forms - Making the impossible possible | FalafelCON 2014
Mobile ASP.Net Web Forms - Making the impossible possible | FalafelCON 2014
FalafelSoftware
 
Introducing ASP.NET vNext – The Future of .NET on the Server | FalafelCON 2014
Introducing ASP.NET vNext – The Future of .NET on the Server | FalafelCON 2014
FalafelSoftware
 
Cloud and Azure and Rock and Roll
Cloud and Azure and Rock and Roll
FalafelSoftware
 
The Hitchhicker’s Guide to Windows Azure Mobile Services | FalafelCON 2014
The Hitchhicker’s Guide to Windows Azure Mobile Services | FalafelCON 2014
FalafelSoftware
 
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
FalafelSoftware
 
AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014
AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014
FalafelSoftware
 
DDD with ASP.NET MVC - Steve Smith | FalafelCON 2014
DDD with ASP.NET MVC - Steve Smith | FalafelCON 2014
FalafelSoftware
 
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
FalafelSoftware
 
Solving Mobile Test Automation Challenges with TestComplete - Nick Olivo | Fa...
Solving Mobile Test Automation Challenges with TestComplete - Nick Olivo | Fa...
FalafelSoftware
 
iBeacons for Everyone, from iOS to Android - James Montemagno | FalafelCON 2014
iBeacons for Everyone, from iOS to Android - James Montemagno | FalafelCON 2014
FalafelSoftware
 
XAML Development with Xamarin - Jesse Liberty | FalafelCON 2014
XAML Development with Xamarin - Jesse Liberty | FalafelCON 2014
FalafelSoftware
 
AngularJS and Kendo UI - Jesse Liberty | FalafelCON 2014
AngularJS and Kendo UI - Jesse Liberty | FalafelCON 2014
FalafelSoftware
 
Agile Patterns: Estimation - Stephen Forte | FalafelCON 2014
Agile Patterns: Estimation - Stephen Forte | FalafelCON 2014
FalafelSoftware
 
Mobile ASP.Net Web Forms - Making the impossible possible | FalafelCON 2014
Mobile ASP.Net Web Forms - Making the impossible possible | FalafelCON 2014
FalafelSoftware
 
Introducing ASP.NET vNext – The Future of .NET on the Server | FalafelCON 2014
Introducing ASP.NET vNext – The Future of .NET on the Server | FalafelCON 2014
FalafelSoftware
 
Cloud and Azure and Rock and Roll
Cloud and Azure and Rock and Roll
FalafelSoftware
 
The Hitchhicker’s Guide to Windows Azure Mobile Services | FalafelCON 2014
The Hitchhicker’s Guide to Windows Azure Mobile Services | FalafelCON 2014
FalafelSoftware
 
Ad

Recently uploaded (20)

University Campus Navigation for All - Peak of Data & AI
University Campus Navigation for All - Peak of Data & AI
Safe Software
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
WSO2
 
Building Geospatial Data Warehouse for GIS by GIS with FME
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
Simplify Task, Team, and Project Management with Orangescrum Work
Simplify Task, Team, and Project Management with Orangescrum Work
Orangescrum
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
arctitecture application system design os dsa
arctitecture application system design os dsa
za241967
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
AI for PV: Development and Governance for a Regulated Industry
AI for PV: Development and Governance for a Regulated Industry
Biologit
 
IObit Driver Booster Pro 12 Crack Latest Version Download
IObit Driver Booster Pro 12 Crack Latest Version Download
pcprocore
 
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 
Advance Doctor Appointment Booking App With Online Payment
Advance Doctor Appointment Booking App With Online Payment
AxisTechnolabs
 
HYBRIDIZATION OF ALKANES AND ALKENES ...
HYBRIDIZATION OF ALKANES AND ALKENES ...
karishmaduhijod1
 
Automated Testing and Safety Analysis of Deep Neural Networks
Automated Testing and Safety Analysis of Deep Neural Networks
Lionel Briand
 
Key Challenges in Troubleshooting Customer On-Premise Applications
Key Challenges in Troubleshooting Customer On-Premise Applications
Tier1 app
 
Sap basis role in public cloud in s/4hana.pptx
Sap basis role in public cloud in s/4hana.pptx
htmlprogrammer987
 
From Data Preparation to Inference: How Alluxio Speeds Up AI
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
Best Software Development at Best Prices
Best Software Development at Best Prices
softechies7
 
Streamlining CI/CD with FME Flow: A Practical Guide
Streamlining CI/CD with FME Flow: A Practical Guide
Safe Software
 
University Campus Navigation for All - Peak of Data & AI
University Campus Navigation for All - Peak of Data & AI
Safe Software
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
WSO2
 
Building Geospatial Data Warehouse for GIS by GIS with FME
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
Simplify Task, Team, and Project Management with Orangescrum Work
Simplify Task, Team, and Project Management with Orangescrum Work
Orangescrum
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
arctitecture application system design os dsa
arctitecture application system design os dsa
za241967
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
AI for PV: Development and Governance for a Regulated Industry
AI for PV: Development and Governance for a Regulated Industry
Biologit
 
IObit Driver Booster Pro 12 Crack Latest Version Download
IObit Driver Booster Pro 12 Crack Latest Version Download
pcprocore
 
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 
Advance Doctor Appointment Booking App With Online Payment
Advance Doctor Appointment Booking App With Online Payment
AxisTechnolabs
 
HYBRIDIZATION OF ALKANES AND ALKENES ...
HYBRIDIZATION OF ALKANES AND ALKENES ...
karishmaduhijod1
 
Automated Testing and Safety Analysis of Deep Neural Networks
Automated Testing and Safety Analysis of Deep Neural Networks
Lionel Briand
 
Key Challenges in Troubleshooting Customer On-Premise Applications
Key Challenges in Troubleshooting Customer On-Premise Applications
Tier1 app
 
Sap basis role in public cloud in s/4hana.pptx
Sap basis role in public cloud in s/4hana.pptx
htmlprogrammer987
 
From Data Preparation to Inference: How Alluxio Speeds Up AI
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
Best Software Development at Best Prices
Best Software Development at Best Prices
softechies7
 
Streamlining CI/CD with FME Flow: A Practical Guide
Streamlining CI/CD with FME Flow: A Practical Guide
Safe Software
 

Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | FalafelCON 2014

  • 1. describe('UnitTes.ng', func.on(){ it('works with AngularJS'… } Jesse Liberty Master Consultant Falafel SoFware [email protected] @jesseliberty
  • 2. What We Will Cover • Why bother? • Why Aren't We Doing It? • Wri.ng specs • Matchers • Spies
  • 3. Getting the terms right § Unit Test § Test Driven Development (TDD) o Test First Development § Behavior Driven Development (BDD)
  • 4. Am I In The Right Presenta7on? • I assume… • Comfort with Angular Fundamentals • No prior experience with unit tes.ng
  • 5. Ques7ons If you get lost it will be hard to catch up so please, please ask ques.ons Copyright © 2003-­‐2014 Falafel SoFware Inc. 5 Q&A at the end
  • 14. Getting Started § What you already need to know o Javascript o Angular § What hardware you need § What software you need § Where to get everything o Getting Jasmine o Finding documentation o Finding Help
  • 17. Red, Green, Rafactor § Red – Your Test Should Fail § Green – Make Your Test Pass § Refactor – Clean up your code without breaking your test
  • 18. Red, Green, Rafactor § Red – Your Test Should Fail § Green – Make Your Test Work § Refactor – Clean up your code without breaking your test Lather Rinse Repeat
  • 19. Three Laws 1. You may not write production code until you have a failing test 2. You may not write more of a unit test than is sufficient to fail 3. You may not write more production code than is sufficient to pass
  • 20. The Prime Directive § Your test code should be as good and well maintained as your production code. o Succinct o Clear o Simple § However, do not worry about efficiency in test code
  • 21. Test One Concept In Each Test § Pass/Fail should immediately convey what was tested and the result
  • 22. F.I.R.S.T. § Fast § Independent § Repeatable § Self-validating (boolean output) § Timely
  • 23. SEE: Setup Execute Check Expectations
  • 34. Demo
  • 40. Matchers § toBe § toEqual § toBeTruthy § toBeNull, toBeUndefined, toBeNaN § toContain § toMatch § toBeLessThan § etc.
  • 54. Demo
  • 62. Demo
  • 63. Custom Matchers • How would we test that an expense item is "reasonable?" • Problem #1 – We'd like to use "ToBeReasonable" • Problem #2 – How will the compare pick out the amount as the value to test? new ExpenseItem( 'taxi', 'Taxi to airport', 89.50);
  • 69. Demo
  • 71. Making An Expense Item § Delete expense.js § Add new parameters to ExpenseItem
  • 74. Requirement: Persist expenses and report number that were persisted
  • 81. Demo
  • 84. Contact Me • Jesse Liberty • Falafel SoFware • [email protected] • @jesseliberty