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
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 Tests
Geoffrey Dunn
 
Agile testingandautomation
Agile testingandautomationAgile testingandautomation
Agile testingandautomation
jeisner
 
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
Bill Shelton
 
Developer Night - Opticon18
Developer Night - Opticon18Developer Night - Opticon18
Developer Night - Opticon18
Optimizely
 
U certify earlybird sale
U certify earlybird saleU certify earlybird sale
U certify earlybird sale
jasminesmith2111
 
Grading the Quality of Selenium Tests
Grading the Quality of Selenium TestsGrading 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 PresentationZen 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 AvivZen 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 MaintenanceZen 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 - iCheckWebsitePatterns 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 ThemDirty tests and How To Clean Them
Dirty tests and How To Clean Them
Gil Zilberfeld
 
Unit testing for Grown-ups
Unit testing for Grown-upsUnit 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)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 codeRefactoring 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...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 PepinoATDD 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...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 Commandments
TerraSky
 
Maintaining Retainers as a WordPress Developer
Maintaining Retainers as a WordPress DeveloperMaintaining 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 2018Top 10 die besten 3D Camcorder in 2018
Top 10 die besten 3D Camcorder in 2018
fudesavylac
 

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 testing
PiXeL16
 
Completely Test-Driven
Completely Test-DrivenCompletely Test-Driven
Completely Test-Driven
Ian 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 Flex
michael.labriola
 
Testacular
TestacularTestacular
Testacular
James Ford
 
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
Winston Laoh
 
TDD and Getting Paid
TDD and Getting PaidTDD and Getting Paid
TDD and Getting Paid
Rowan Merewood
 
iOS Test-Driven Development
iOS Test-Driven DevelopmentiOS Test-Driven Development
iOS Test-Driven Development
Pablo Villar
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx
AmalEldhose2
 
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
Shawn Jones
 
Test Driven
Test DrivenTest Driven
Test Driven
Alex Chaffee
 
Test Driven Development with Laravel
Test Driven Development with LaravelTest Driven Development with Laravel
Test Driven Development with Laravel
Tyler Johnston
 
Test-Driven Development
 Test-Driven Development  Test-Driven Development
Test-Driven Development
Amir Assad
 
Testing recipes
Testing recipesTesting 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
Blue 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 PDX
Evan Solomon
 
An Introduction to unit testing
An Introduction to unit testingAn Introduction to unit testing
An Introduction to unit testing
Steven Casey
 
Apex 10 commandments df14
Apex 10 commandments df14Apex 10 commandments df14
Apex 10 commandments df14
James 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 2019
Paulo Clavijo
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
Attila Bertók
 
Intro to TDD
Intro to TDDIntro to TDD
Intro to TDD
Jason Nocks
 

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 2014
FalafelSoftware
 
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
FalafelSoftware
 
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
FalafelSoftware
 
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 2014
FalafelSoftware
 
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
FalafelSoftware
 
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
FalafelSoftware
 
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
FalafelSoftware
 
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
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 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
FalafelSoftware
 
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
FalafelSoftware
 
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
FalafelSoftware
 

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

Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 

Recently uploaded (20)

Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 

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