Introduction to TDD

or

Testing all the codes so you can sleep at night

Objectives

  • Describe what TDD is
  • Describe why testing is important
  • Write a canary test
  • Test the happy path
  • Test assuming your user is a hacker

What is TDD?

A Tester walks into a bar

He orders

  • 1 beer
  • 10 beers
  • 0 beers
  • an elephant

Why test?

Its one of the only ways to know for certain that your code is working the way that you intend.

Also, its easy to accidentaly break another part of your program

Check for Understanding

Cold call

What is TDD?

Check for Understanding

Cold call

Why should we test?

I do

I am going to open the assessment and write a test

I do

That type of test is called a canary test

I do

Now I'm going to test one possible happy path

You do

In your assessment

Create a canary test and a happy path test

For a 3

Make sure that you also test that the function can handle bad input

It expects a string? Give it a number

 

Give it nothing, give it a function, give it an object...

The code should handle failure in an expected way

You do

Write your tests for the assessment

tdd

By Brooks Patton

tdd

Intro to test driven development with Node.js, mocha, and chai

  • 1,020