Development Testing for Dummies

In the software engineering community, there is a growing buzz for engineers that have proficiency in unit testing. Typically, you’ll hear people debate between the uses and efficiencies of two forms of testing- Test-Driven Development (TDD) and Behavior-Driven Development (BDD). But if you’re new to the tech world, like me, you’ll find these foreign terms a bit confusing. Let’s take a look.

To understand the differences between the two testing paradigms, let’s first break down the idea of “unit testing”. Unit tests are exactly what the name suggest- a test for a unit. These tests focus on one particular bit of code, and test the functionality of whatever you’re building. For example, if you’re working on a calculator application, and you want to test the accuracy of the subtraction functionality, you would write a unit test to see if 8 — 6 = 2. Because these tests are designed for only a single unit of a larger structure, the tests are simple and quick.

Now, let’s dive a little deeper and look more specific forms of unit testing. Test-Driven Development (TDD) follows a distinct pattern of initially writing a test for a function that you would like to build, making sure the test fails because of the absence of the soon-to-be-built feature, writing the simplest code to pass the test, and then improving the code and tests until you have a fully-developed feature.

Behavior-Driven Development (BDD) is very similar to TDD, in which it requires all of the same steps, but is thought of more as a guide for best practices when writing test. Instead of solely relying on what the input and outcomes of a function are (i.e. when you input 8 and 6 into a subtraction function, will we receive 2?), BDD targets the inner behaviors of a function, and tests to see if what’s happening in the code is what is supposed to happen (i.e. when you take two numbers, is one number is taken away from the other, and giving you the amount leftover?).

Though BDD and TDD do sound very similar, it is fair to think of BDD as a guide to good TDD. But whether you feel that BDD is TDD done correctly, or that these two schools of testing are completely different, there is one thing we can all agree on: write your tests!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.