Book Image

Node.js Blueprints

By : Krasimir Stefanov Tsonev
Book Image

Node.js Blueprints

By: Krasimir Stefanov Tsonev

Overview of this book

Table of Contents (19 chapters)
Node.js Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Choosing a testing methodology


There are few popular ways of writing tests. Let's see which are they and the differences between them.

Test-driven development

Test-driven development (TDD) is a process that relies on the repetition of short development cycles. In other words, we write our test while writing the implementation. The shorter the cycles, the better. The following diagram shows the TDD flow:

Before we write the actual code that does the job for us, we need to prepare a test. Of course, after the first run, the test will fail because nothing has been implemented. So, we need to ensure that the test passes all the cycles. Once this happens, we may spend some time refactoring what has been done so far and continue with the next method, class, or feature. Note that everything spins around the test, which is a really good thing because this is where we define what our code should do. With this as a basis, we avoid delivering unnecessary code. We can also be sure that the implementation...