SlideShare une entreprise Scribd logo
1  sur  26
Télécharger pour lire hors ligne
NodeJS:
                         Writing Tests
                           A Beginners’ Guide
                   Docs: http://conancat.github.com/node-test-examples/
                  Github: https://github.com/conancat/node-test-examples



                                 Prepared by Grey Ang
                            @conancat | conancat@gmail.com



Wednesday, April 3, 13
Why write tests?



Wednesday, April 3, 13
Programming should be fun




Wednesday, April 3, 13
...and not
                         frustrating.



Wednesday, April 3, 13
The biggest joy in
                    programming is knowing
                      what you write does
                     what it intended to do,
                      and it doesn’t break
                         anything else.

Wednesday, April 3, 13
We all want a peace of
                      mind. Nirvana.




Wednesday, April 3, 13
...but we’re all lazy asses.
                         Trust me, I know. I am one too.




Wednesday, April 3, 13
Most common excuses to
                    not write tests
                         Laziness: “Writing tests is such a chore!”

                         Perceived busyness: “We have too many things to
                         do! We have other targets to hit!”

                         Overconfidence: “This function is really easy. I can
                         handle this.”

                         Ego: “Come on, real men doesn’t need to test their
                         code. It’ll definitely work. Trust me, I’m a
                         programmer.”


Wednesday, April 3, 13
What are the
                         consequences?



Wednesday, April 3, 13
96% of programmers do this to their
                         computers at least once a week.

                         (Okay, I made up that number.
                         But we all know how that feels.)




Wednesday, April 3, 13
Shit programmers deal with
                          Old code breaks when      Your code just broke other
                          you write new code        people’s code

                          Code that you wrote is    You spend 8 hours
                          slow as hell              debugging your code and
                                                    other people’s code
                          What you’ve done is not
                          what it supposed to do    ...to name a few.

Wednesday, April 3, 13
Whose fault is it?
              Yours, of course.




Wednesday, April 3, 13
If you’re a true lazy
                    programmer that doesn’t
                    wanna deal with all that
                        shit, write tests.
                         Mark my words. You won’t regret it.




Wednesday, April 3, 13
TDD & BDD
                         Two jargons you should know
                                since yesterday




Wednesday, April 3, 13
Test Driven
                    Development (TDD)
                   “...the developer writes an (initially failing)
                   automated test case that defines a desired
                   improvement or new function, then produces
                   the minimum amount of code to pass that test,
                   and finally refactors the new code to
                   acceptable standards.”

                   http://en.wikipedia.org/wiki/Test-driven_development


Wednesday, April 3, 13
Test Driven
                    Development (TDD)
                         Step 1: Write Test

                         Step 2: Run the test.
                         (It will fail, trust me. It’s okay. Take a deep breath. )

                         Step 3: Write the MINIMUM AMOUNT code to make
                         the test pass

                         Step 4: Test performance of code to optimal levels

                         Step 5: Celebrate that your code works wonderfully

                         Step 6: Write tests, rinse and repeat.

Wednesday, April 3, 13
Problems with traditional TDD
                         Test cases are written for the code -- not for the
                         manager, client, or the users of the system.

                         Code works with the test, code passes the test, but
                         code FAIL with user behavior or client requirements.

                         Traditional TDD is great for development. But if we
                         want code that WORKS, we need to involve the people
                         who spec the app.

                         Remember, code is written for the benefit of people!



Wednesday, April 3, 13
Introducing
                         Behavior Driven
                          Development
                         It’s just like TDD, really. Only better.




Wednesday, April 3, 13
Behavior Driven
                    Development (BDD)
                   “...combines the general techniques and
                   principles of TDD with ideas from domain-
                   driven design and object-oriented analysis
                   and design to provide software developers
                   and business analysts with shared tools and a
                   shared process to collaborate on software
                   development.”
                    http://en.wikipedia.org/wiki/Behavior-driven_development


Wednesday, April 3, 13
Behavior Driven
                    Development (BDD)
                         Step 1: Gather (and argue) requirements from the business side
                         or your users on what should be done

                         Step 2: Write test cases to meet the pre-defined business
                         requirements

                         Step 3: Write the MINIMUM AMOUNT code to make the test
                         pass

                         Step 4: Show it to your business partner

                         Step 5: ???

                         Step 6: Profit!

Wednesday, April 3, 13
“With great power,
                            comes great
                          responsibility.”
                           -- Uncle Ben, Spiderman




Wednesday, April 3, 13
You’re a web developer.
                              You make websites.

                         You’re Spiderman.
                         Remember, you work with machines AND people.
                                   You write code for people.




Wednesday, April 3, 13
4 Test Situations
                          that we’ll be doing today

                         Functional and module testing

                         Handling database calls

                         Testing REST API layers

                         Headless browser testing



Wednesday, April 3, 13
Best way to learn is by
                    doing it yourself.
                     So, lift your lazy ass and go clone this repo
                     and start playing around.

                     https://github.com/conancat/node-test-examples




Wednesday, April 3, 13
Need help? SHOUT!
                            Or you can just talk to me at
                         @conancat on Twitter, or email me at
                               conancat@gmail.com.




Wednesday, April 3, 13
Thanks for coming!
                             Be a good Spiderman!




Wednesday, April 3, 13

Contenu connexe

Similaire à NodeJS: Writing tests -- A Beginners' Guide

10 tips to save you time and frustration while programming
10 tips to save you time and frustration while programming10 tips to save you time and frustration while programming
10 tips to save you time and frustration while programmingHugo Shi
 
Fault Tolerance 101
Fault Tolerance 101 Fault Tolerance 101
Fault Tolerance 101 C4Media
 
Documentation for developers
Documentation for developersDocumentation for developers
Documentation for developersMichael Marotta
 
Engineering culture
Engineering cultureEngineering culture
Engineering culturePamela Fox
 
On Readability of Code
On Readability of CodeOn Readability of Code
On Readability of CodeArun Saha
 
97 thingseveryprogrammershouldknow
97 thingseveryprogrammershouldknow97 thingseveryprogrammershouldknow
97 thingseveryprogrammershouldknowREHAN KHAN
 
Selective 97 things every programmer should know
Selective 97 things every programmer should knowSelective 97 things every programmer should know
Selective 97 things every programmer should knowMuhammad Ahsan
 
Road map to competitive programming
Road map to competitive programmingRoad map to competitive programming
Road map to competitive programmingTutort Academy
 
Cinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patternsCinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patternsSteven Smith
 
Joxean Koret - Interactive Static Analysis Tools for Vulnerability Discovery ...
Joxean Koret - Interactive Static Analysis Tools for Vulnerability Discovery ...Joxean Koret - Interactive Static Analysis Tools for Vulnerability Discovery ...
Joxean Koret - Interactive Static Analysis Tools for Vulnerability Discovery ...RootedCON
 
apidays LIVE New York 2021 - Why Software Teams Struggle with API Security Te...
apidays LIVE New York 2021 - Why Software Teams Struggle with API Security Te...apidays LIVE New York 2021 - Why Software Teams Struggle with API Security Te...
apidays LIVE New York 2021 - Why Software Teams Struggle with API Security Te...apidays
 
Culture And Aesthetic Revisited
Culture And Aesthetic RevisitedCulture And Aesthetic Revisited
Culture And Aesthetic RevisitedAdam Keys
 
Coding Camp Day 1 Presentation
Coding Camp Day 1 PresentationCoding Camp Day 1 Presentation
Coding Camp Day 1 PresentationAnnamarie Carlson
 
Software Debugging for High-altitude Balloons
Software Debugging for High-altitude BalloonsSoftware Debugging for High-altitude Balloons
Software Debugging for High-altitude Balloonsjgrahamc
 
The Data-First approach to Learning Coding 2.0
The Data-First approach to Learning Coding 2.0The Data-First approach to Learning Coding 2.0
The Data-First approach to Learning Coding 2.0Ato Mensah
 
Untangling spring week8
Untangling spring week8Untangling spring week8
Untangling spring week8Derek Jacoby
 

Similaire à NodeJS: Writing tests -- A Beginners' Guide (20)

10 tips to save you time and frustration while programming
10 tips to save you time and frustration while programming10 tips to save you time and frustration while programming
10 tips to save you time and frustration while programming
 
Fault Tolerance 101
Fault Tolerance 101 Fault Tolerance 101
Fault Tolerance 101
 
Pair Programming
Pair ProgrammingPair Programming
Pair Programming
 
Software development
Software developmentSoftware development
Software development
 
Documentation for developers
Documentation for developersDocumentation for developers
Documentation for developers
 
Engineering culture
Engineering cultureEngineering culture
Engineering culture
 
On Readability of Code
On Readability of CodeOn Readability of Code
On Readability of Code
 
97 thingseveryprogrammershouldknow
97 thingseveryprogrammershouldknow97 thingseveryprogrammershouldknow
97 thingseveryprogrammershouldknow
 
Selective 97 things every programmer should know
Selective 97 things every programmer should knowSelective 97 things every programmer should know
Selective 97 things every programmer should know
 
Road map to competitive programming
Road map to competitive programmingRoad map to competitive programming
Road map to competitive programming
 
Cinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patternsCinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patterns
 
Joxean Koret - Interactive Static Analysis Tools for Vulnerability Discovery ...
Joxean Koret - Interactive Static Analysis Tools for Vulnerability Discovery ...Joxean Koret - Interactive Static Analysis Tools for Vulnerability Discovery ...
Joxean Koret - Interactive Static Analysis Tools for Vulnerability Discovery ...
 
apidays LIVE New York 2021 - Why Software Teams Struggle with API Security Te...
apidays LIVE New York 2021 - Why Software Teams Struggle with API Security Te...apidays LIVE New York 2021 - Why Software Teams Struggle with API Security Te...
apidays LIVE New York 2021 - Why Software Teams Struggle with API Security Te...
 
Culture And Aesthetic Revisited
Culture And Aesthetic RevisitedCulture And Aesthetic Revisited
Culture And Aesthetic Revisited
 
Coding Camp Day 1 Presentation
Coding Camp Day 1 PresentationCoding Camp Day 1 Presentation
Coding Camp Day 1 Presentation
 
Coding Camp Day 1
Coding Camp Day 1Coding Camp Day 1
Coding Camp Day 1
 
Software Debugging for High-altitude Balloons
Software Debugging for High-altitude BalloonsSoftware Debugging for High-altitude Balloons
Software Debugging for High-altitude Balloons
 
The Data-First approach to Learning Coding 2.0
The Data-First approach to Learning Coding 2.0The Data-First approach to Learning Coding 2.0
The Data-First approach to Learning Coding 2.0
 
Untangling spring week8
Untangling spring week8Untangling spring week8
Untangling spring week8
 
When Tdd Goes Awry
When Tdd Goes AwryWhen Tdd Goes Awry
When Tdd Goes Awry
 

Dernier

MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 

Dernier (20)

MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 

NodeJS: Writing tests -- A Beginners' Guide

  • 1. NodeJS: Writing Tests A Beginners’ Guide Docs: http://conancat.github.com/node-test-examples/ Github: https://github.com/conancat/node-test-examples Prepared by Grey Ang @conancat | conancat@gmail.com Wednesday, April 3, 13
  • 3. Programming should be fun Wednesday, April 3, 13
  • 4. ...and not frustrating. Wednesday, April 3, 13
  • 5. The biggest joy in programming is knowing what you write does what it intended to do, and it doesn’t break anything else. Wednesday, April 3, 13
  • 6. We all want a peace of mind. Nirvana. Wednesday, April 3, 13
  • 7. ...but we’re all lazy asses. Trust me, I know. I am one too. Wednesday, April 3, 13
  • 8. Most common excuses to not write tests Laziness: “Writing tests is such a chore!” Perceived busyness: “We have too many things to do! We have other targets to hit!” Overconfidence: “This function is really easy. I can handle this.” Ego: “Come on, real men doesn’t need to test their code. It’ll definitely work. Trust me, I’m a programmer.” Wednesday, April 3, 13
  • 9. What are the consequences? Wednesday, April 3, 13
  • 10. 96% of programmers do this to their computers at least once a week. (Okay, I made up that number. But we all know how that feels.) Wednesday, April 3, 13
  • 11. Shit programmers deal with Old code breaks when Your code just broke other you write new code people’s code Code that you wrote is You spend 8 hours slow as hell debugging your code and other people’s code What you’ve done is not what it supposed to do ...to name a few. Wednesday, April 3, 13
  • 12. Whose fault is it? Yours, of course. Wednesday, April 3, 13
  • 13. If you’re a true lazy programmer that doesn’t wanna deal with all that shit, write tests. Mark my words. You won’t regret it. Wednesday, April 3, 13
  • 14. TDD & BDD Two jargons you should know since yesterday Wednesday, April 3, 13
  • 15. Test Driven Development (TDD) “...the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally refactors the new code to acceptable standards.” http://en.wikipedia.org/wiki/Test-driven_development Wednesday, April 3, 13
  • 16. Test Driven Development (TDD) Step 1: Write Test Step 2: Run the test. (It will fail, trust me. It’s okay. Take a deep breath. ) Step 3: Write the MINIMUM AMOUNT code to make the test pass Step 4: Test performance of code to optimal levels Step 5: Celebrate that your code works wonderfully Step 6: Write tests, rinse and repeat. Wednesday, April 3, 13
  • 17. Problems with traditional TDD Test cases are written for the code -- not for the manager, client, or the users of the system. Code works with the test, code passes the test, but code FAIL with user behavior or client requirements. Traditional TDD is great for development. But if we want code that WORKS, we need to involve the people who spec the app. Remember, code is written for the benefit of people! Wednesday, April 3, 13
  • 18. Introducing Behavior Driven Development It’s just like TDD, really. Only better. Wednesday, April 3, 13
  • 19. Behavior Driven Development (BDD) “...combines the general techniques and principles of TDD with ideas from domain- driven design and object-oriented analysis and design to provide software developers and business analysts with shared tools and a shared process to collaborate on software development.” http://en.wikipedia.org/wiki/Behavior-driven_development Wednesday, April 3, 13
  • 20. Behavior Driven Development (BDD) Step 1: Gather (and argue) requirements from the business side or your users on what should be done Step 2: Write test cases to meet the pre-defined business requirements Step 3: Write the MINIMUM AMOUNT code to make the test pass Step 4: Show it to your business partner Step 5: ??? Step 6: Profit! Wednesday, April 3, 13
  • 21. “With great power, comes great responsibility.” -- Uncle Ben, Spiderman Wednesday, April 3, 13
  • 22. You’re a web developer. You make websites. You’re Spiderman. Remember, you work with machines AND people. You write code for people. Wednesday, April 3, 13
  • 23. 4 Test Situations that we’ll be doing today Functional and module testing Handling database calls Testing REST API layers Headless browser testing Wednesday, April 3, 13
  • 24. Best way to learn is by doing it yourself. So, lift your lazy ass and go clone this repo and start playing around. https://github.com/conancat/node-test-examples Wednesday, April 3, 13
  • 25. Need help? SHOUT! Or you can just talk to me at @conancat on Twitter, or email me at conancat@gmail.com. Wednesday, April 3, 13
  • 26. Thanks for coming! Be a good Spiderman! Wednesday, April 3, 13