A complete introduction to unit testing, and test-first development for AngularJS programmers. Topics include tools, specs, test runners, core testing practices and patterns, Behavior-driven development, Spys, Matchers, Stubs and MOcks and much more.
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
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);