What is TDD?

Whether you’re new to software development or have been around for awhile, you may have heard of TDD, but have never really gotten a full explanation of the process and benefits of adoption. The purpose of this post is to give you a quick introduction to TDD and hopefully pique your interest if you don’t already have TDD in your arsenal of tools.

So what is TDD? To put it simply,

TDD (Test Driven Development) is a methodology of developing software
that relies on very short feedback loops using unit tests.

To practice TDD, start with a failing unit test. Then write only enough code to make that test pass. Finally, refactor the production and unit test code you’ve written. Repeat. This cycle is often called Red Green Refactor cycle. …

In my previous post, Angular Component Class Tests, I shared why I prefer to write my Angular unit tests exclusively as component class tests. In this post, I want to share a simple function I use to create typed stubs.

In my previous post, you’ll notice I had to cast my dependencies to the Typescript any type in order to inject them into the constructor. Here’s that example again:

Image for post
Image for post
Photo by Daniel von Appen on Unsplash

When testing Angular components, I almost exclusively use component class tests. These are tests that do not use the TestBed and allow you to test a component the same way you would test a service.

The main reason I prefer component class tests is that they are much easier to write than using the TestBed. …


John Oerter

Software Developer from Omaha, NE.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store