TEST DRIVEN DEVELOPMENT

LEARNING OBJECTIVES

- Explain WHY tdd

- Identify two testing libraries for Node.js

- List the parts of a test

- Describe the TDD flow

 

- Saves Time

- Prevent Regressions

- Design Better Code

- Serve as documentation

WHY TDD

Testing isn't something you just have to do...

it is a mindset that helps you write more robust code.

- Chai

- Mocha

- Jasmine

- QUnit

- & many, many more...

 

TIPS: 

Don't get caught up in specifics

Deeply grok the principles

It's OK to look up the syntax!!

FRAMEWORKS

- Assertions (matchers)

- Test runner

- Utilities (ex: °F to °C)

     lodash

-Fixtures (data)

PARTS

3 steps of TDD flow?

3

1. THINK (write the test)

2. Run the test and watch it fail (RED)

3. Make minimal changes to pass the test (GREEN)

4. Refactor to reduce redundancy

5. Re-run the test at each change to see if the test passes
...

4. Repeat with additional cases

TDD FLOW

A user...
  Has a first name which:

  - Is not an empty string

  - Does not contain special characters

GOALS:

Satisfy Requirement

A secondary goal of TDD is to serve as documentation of the code's behavior in a human comprehendible (not just human readable) format.

 

For example, the first statement, "A User", frames what the test group is talking about.

GOALS:

Documentation

LEARNING OBJECTIVES

- Explain WHY tdd

- Identify two testing libraries for Node.js

- List the parts of a test

- Describe the TDD flow

Made with Slides.com