SlideShare a Scribd company logo
1 of 84
Download to read offline
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
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
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
Demo
Measuring your step size
Matchers
Matchers 
§ toBe 
§ toEqual 
§ toBeTruthy 
§ toBeNull, toBeUndefined, toBeNaN 
§ toContain 
§ toMatch 
§ toBeLessThan 
§ etc.
Demo
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
Demo
Making An Expense Item 
§ Delete expense.js 
§ Add new parameters to ExpenseItem
Requirement: 
Persist 
expenses 
and 
report 
number 
that 
were 
persisted
Demo
Ques7ons? 
Contact 
me: 
jesse@falafel.com 
@jesseliberty
Contact Me 
• Jesse 
Liberty 
• Falafel 
SoFware 
• jesse@falafel.com 
• @jesseliberty

More Related Content

What's hot

Helping Programmers Write Better Tests
Helping Programmers Write Better TestsHelping Programmers Write Better Tests
Helping Programmers Write Better TestsGeoffrey Dunn
 
Agile testingandautomation
Agile testingandautomationAgile testingandautomation
Agile testingandautomationjeisner
 
Learn Unit Testing and Improve Sexual Performance
Learn Unit Testing and Improve Sexual PerformanceLearn Unit Testing and Improve Sexual Performance
Learn Unit Testing and Improve Sexual PerformanceBill Shelton
 
Developer Night - Opticon18
Developer Night - Opticon18Developer Night - Opticon18
Developer Night - Opticon18Optimizely
 
Grading the Quality of Selenium Tests
Grading the Quality of Selenium TestsGrading the Quality of Selenium Tests
Grading the Quality of Selenium TestsMarcus Merrell
 
Zen And the Art of Test Maintenance Presentation
Zen And the Art of Test Maintenance PresentationZen And the Art of Test Maintenance Presentation
Zen And the Art of Test Maintenance PresentationGil Zilberfeld
 
Zen and the art of Test Maintenance - #TestIL Meetup Tel Aviv
Zen and the art of Test Maintenance - #TestIL Meetup Tel AvivZen and the art of Test Maintenance - #TestIL Meetup Tel Aviv
Zen and the art of Test Maintenance - #TestIL Meetup Tel AvivGil Zilberfeld
 
Zen and the Art of Test Maintenance
Zen and the Art of Test MaintenanceZen and the Art of Test Maintenance
Zen and the Art of Test MaintenanceGil Zilberfeld
 
Patterns in Testing and a claim - iCheckWebsite
Patterns in Testing and a claim - iCheckWebsitePatterns in Testing and a claim - iCheckWebsite
Patterns in Testing and a claim - iCheckWebsiteAnand Ramdeo
 
Dirty tests and How To Clean Them
Dirty tests and How To Clean ThemDirty tests and How To Clean Them
Dirty tests and How To Clean ThemGil Zilberfeld
 
Unit testing for Grown-ups
Unit testing for Grown-upsUnit testing for Grown-ups
Unit testing for Grown-upsGil Zilberfeld
 
Living with acceptance tests: Beyond Write-Once (XP NYC)
Living with acceptance tests: Beyond Write-Once (XP NYC)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...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...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 Commandments4 TSPN_Apex 10 Commandments
4 TSPN_Apex 10 CommandmentsTerraSky
 
Maintaining Retainers as a WordPress Developer
Maintaining Retainers as a WordPress DeveloperMaintaining Retainers as a WordPress Developer
Maintaining Retainers as a WordPress DeveloperDevinVinson
 
Top 10 die besten 3D Camcorder in 2018
Top 10 die besten 3D Camcorder in 2018Top 10 die besten 3D Camcorder in 2018
Top 10 die besten 3D Camcorder in 2018fudesavylac
 

What's hot (20)

Helping Programmers Write Better Tests
Helping Programmers Write Better TestsHelping Programmers Write Better Tests
Helping Programmers Write Better Tests
 
Agile testingandautomation
Agile testingandautomationAgile testingandautomation
Agile testingandautomation
 
Learn Unit Testing and Improve Sexual Performance
Learn Unit Testing and Improve Sexual PerformanceLearn Unit Testing and Improve Sexual Performance
Learn Unit Testing and Improve Sexual Performance
 
Developer Night - Opticon18
Developer Night - Opticon18Developer Night - Opticon18
Developer Night - Opticon18
 
U certify earlybird sale
U certify earlybird saleU certify earlybird sale
U certify earlybird sale
 
Grading the Quality of Selenium Tests
Grading the Quality of Selenium TestsGrading the Quality of Selenium Tests
Grading the Quality of Selenium Tests
 
Zen And the Art of Test Maintenance Presentation
Zen And the Art of Test Maintenance PresentationZen And the Art of Test Maintenance Presentation
Zen And the Art of Test Maintenance Presentation
 
Zen and the art of Test Maintenance - #TestIL Meetup Tel Aviv
Zen and the art of Test Maintenance - #TestIL Meetup Tel AvivZen and the art of Test Maintenance - #TestIL Meetup Tel Aviv
Zen and the art of Test Maintenance - #TestIL Meetup Tel Aviv
 
Zen and the Art of Test Maintenance
Zen and the Art of Test MaintenanceZen and the Art of Test Maintenance
Zen and the Art of Test Maintenance
 
Patterns in Testing and a claim - iCheckWebsite
Patterns in Testing and a claim - iCheckWebsitePatterns in Testing and a claim - iCheckWebsite
Patterns in Testing and a claim - iCheckWebsite
 
Dirty tests and How To Clean Them
Dirty tests and How To Clean ThemDirty tests and How To Clean Them
Dirty tests and How To Clean Them
 
Unit testing for Grown-ups
Unit testing for Grown-upsUnit testing for Grown-ups
Unit testing for Grown-ups
 
Living with acceptance tests: Beyond Write-Once (XP NYC)
Living with acceptance tests: Beyond Write-Once (XP NYC)Living with acceptance tests: Beyond Write-Once (XP NYC)
Living with acceptance tests: Beyond Write-Once (XP NYC)
 
Refactoring legacy code
Refactoring legacy codeRefactoring legacy code
Refactoring legacy code
 
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...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...
 
ATDD with Pepino
ATDD with PepinoATDD with Pepino
ATDD with Pepino
 
Agile Network India | Be Customer Centric with Test First Development | Mamat...
Agile Network India | Be Customer Centric with Test First Development | Mamat...Agile Network India | Be Customer Centric with Test First Development | Mamat...
Agile Network India | Be Customer Centric with Test First Development | Mamat...
 
4 TSPN_Apex 10 Commandments
4 TSPN_Apex 10 Commandments4 TSPN_Apex 10 Commandments
4 TSPN_Apex 10 Commandments
 
Maintaining Retainers as a WordPress Developer
Maintaining Retainers as a WordPress DeveloperMaintaining Retainers as a WordPress Developer
Maintaining Retainers as a WordPress Developer
 
Top 10 die besten 3D Camcorder in 2018
Top 10 die besten 3D Camcorder in 2018Top 10 die besten 3D Camcorder in 2018
Top 10 die besten 3D Camcorder in 2018
 

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

Unit testing
Unit testingUnit testing
Unit testingPiXeL16
 
Completely Test-Driven
Completely Test-DrivenCompletely Test-Driven
Completely Test-DrivenIan Truslove
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flexmichael.labriola
 
Fantastic Tests - The Crimes of Bad Test Design
Fantastic Tests - The Crimes of Bad Test DesignFantastic Tests - The Crimes of Bad Test Design
Fantastic Tests - The Crimes of Bad Test DesignWinston Laoh
 
iOS Test-Driven Development
iOS Test-Driven DevelopmentiOS Test-Driven Development
iOS Test-Driven DevelopmentPablo Villar
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptxAmalEldhose2
 
A Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentA Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentShawn Jones
 
Test Driven Development with Laravel
Test Driven Development with LaravelTest Driven Development with Laravel
Test Driven Development with LaravelTyler Johnston
 
Test-Driven Development
 Test-Driven Development  Test-Driven Development
Test-Driven Development Amir Assad
 
An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1Blue Elephant Consulting
 
You have no idea what your users want - WordCamp PDX
You have no idea what your users want - WordCamp PDXYou have no idea what your users want - WordCamp PDX
You have no idea what your users want - WordCamp PDXEvan Solomon
 
An Introduction to unit testing
An Introduction to unit testingAn Introduction to unit testing
An Introduction to unit testingSteven Casey
 
Apex 10 commandments df14
Apex 10 commandments df14Apex 10 commandments df14
Apex 10 commandments df14James Loghry
 
TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019Paulo Clavijo
 

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

Unit testing
Unit testingUnit testing
Unit testing
 
Completely Test-Driven
Completely Test-DrivenCompletely Test-Driven
Completely Test-Driven
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
Testacular
TestacularTestacular
Testacular
 
Fantastic Tests - The Crimes of Bad Test Design
Fantastic Tests - The Crimes of Bad Test DesignFantastic Tests - The Crimes of Bad Test Design
Fantastic Tests - The Crimes of Bad Test Design
 
TDD and Getting Paid
TDD and Getting PaidTDD and Getting Paid
TDD and Getting Paid
 
iOS Test-Driven Development
iOS Test-Driven DevelopmentiOS Test-Driven Development
iOS Test-Driven Development
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx
 
A Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentA Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven Development
 
Test Driven
Test DrivenTest Driven
Test Driven
 
Test Driven Development with Laravel
Test Driven Development with LaravelTest Driven Development with Laravel
Test Driven Development with Laravel
 
Test-Driven Development
 Test-Driven Development  Test-Driven Development
Test-Driven Development
 
Testing recipes
Testing recipesTesting recipes
Testing recipes
 
An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1
 
You have no idea what your users want - WordCamp PDX
You have no idea what your users want - WordCamp PDXYou have no idea what your users want - WordCamp PDX
You have no idea what your users want - WordCamp PDX
 
An Introduction to unit testing
An Introduction to unit testingAn Introduction to unit testing
An Introduction to unit testing
 
Apex 10 commandments df14
Apex 10 commandments df14Apex 10 commandments df14
Apex 10 commandments df14
 
TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
 
Intro to TDD
Intro to TDDIntro to TDD
Intro to TDD
 

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

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

Recently uploaded

A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationHelp Desk Migration
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)Max Lee
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAlluxio, Inc.
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfQ-Advise
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfFurqanuddin10
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024Shane Coughlan
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Andrea Goulet
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfkalichargn70th171
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAlluxio, Inc.
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfMehmet Akar
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAlluxio, Inc.
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesNeo4j
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabbereGrabber
 
Workforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfWorkforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfDeskTrack
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Krakówbim.edu.pl
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion Clinic
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesKrzysztofKkol1
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...rajkumar669520
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignNeo4j
 

Recently uploaded (20)

A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data Migration
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdf
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdf
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
Workforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfWorkforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdf
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 

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 jesse@falafel.com @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
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 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
  • 16.
  • 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
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34. Demo
  • 36.
  • 37.
  • 38.
  • 40. Matchers § toBe § toEqual § toBeTruthy § toBeNull, toBeUndefined, toBeNaN § toContain § toMatch § toBeLessThan § etc.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54. Demo
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 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);
  • 65.
  • 66.
  • 67.
  • 68.
  • 69. Demo
  • 70.
  • 71. Making An Expense Item § Delete expense.js § Add new parameters to ExpenseItem
  • 72.
  • 73.
  • 74. Requirement: Persist expenses and report number that were persisted
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81. Demo
  • 82.
  • 83. Ques7ons? Contact me: jesse@falafel.com @jesseliberty
  • 84. Contact Me • Jesse Liberty • Falafel SoFware • jesse@falafel.com • @jesseliberty