You are doing it wrong if you are not using test first
Tags: people, process, atdd, tdd
Published: 2017-12-29 18:29:09

---
title: "You are doing it wrong if you are not using test first"
published: true
tags: People, Process,ATDD,TDD
canonical_url: https://nkdagility.com/you-are-doing-it-wrong-if-you-are-not-using-test-first/
---

Many teams are struggling with delivering modern software because they are not building with Test First Principals. Test First gives us the assurance that we have built the correct thing, that what we built is what the customer asked for and that when we change things we don’t break anything inadvertently.

## TL;DR;

While it takes time, effort, dedication and discipline to achieve Test First the return on investment is enormous. A common form of Test First is Test Driven Development (TDD) and we can use it to meet more of our customer’s expectations, minimise our maintenance costs, and get fewer regressions and bugs in production. Ultimately without working in a test first culture, you will be [unable to do continuous delivery](https://nkdagility.com/continuous-deliver-sprint/) with any confidence.

The only question for a [Professional Development Team](https://nkdagility.com/training/courses/professional-scrum-developer-training/) is how to get started.

## You are doing it wrong if you are not using test first

If you look up Test First on Wikipedia you will be redirected to the Test Driven Development (TDD) page and I believe this to be incorrect. While TDD is one, arguably the most effective, form of Test First it is by no means the whole thing. Can I achieve Test First with no automation at all: Yes. Can I do TDD with no automation at all: No. Do you see my conflict…

> **_If you are building applications without writing your tests first then you are doing it wrong. Your process will result in significant rework, be less maintainable and be less likely to meet the customers needs._** <small><strong>Scottish Software Proverb</strong> (just made it up, and I am Scottish)</small>

Unfortunately, while the proverb above is absolutely true there are many fanatics that will not accept that you can do test-first without automation. Just like the **Process Wars** , the **Practice Wars** are being waged around us, and while we want to endeavour to be agnostic it is not possible to be an atheist.

You will hear a lot of different terms banded about in relations to test first:

- **Test-Driven Development (TDD)** – Automated tests created before the code is written to validate that we need that code.
- **Acceptance Test Driven Development (ATDD)** – Tests, either automated or manual, that validate business functionality
- **Behaviour Driven Development (BDD)** – An automated test that validates a particular behaviour that you want your application to have.
- etc…
> All of these topics, and more, are covered in the [Professional Scrum Developer (PSD) training](https://nkdagility.com/training/courses/professional-scrum-developer-training/) that was build in combination with Scrum.org and Microsoft as the only official team training for Scrum & DevOps.

These terms all fulfil a specific niche and the evolution of modern software development will sprout many more. Find that which solves your specific problem and adapt until you have something that works for you, your team and your organisation.

## The essence of test first

Test First has two main goals, both of which are as important as each other.

The first is about professionally validating that which you have built. Software Development is complicated and one can easily create unintended results when that code is executed. This is not a quotient of poor programming but of the complexity of the task. In the eighteen hundreds, plumbers pumped smoke through the pipes to make sure that there were no leaks on the grounds that if it is good enough for the smoke it is good enough for water. This mentality has resulted in what we now call the ‘smoke test’ in software development and the result of its implementation is bugs in production. When compared to software development plumbing is simple; modern software is many times more complex than Software was even 10 years ago. We have accepted poor quality deliverables and expensive maintenance for far too long.

The second goal is to shorten your feedback loops. The closer our engineers are to when the problem was created the quicker they can find it and the cheaper it is to fix. Unfortunately, it is impossible to tell in most software what ‘right’ looks like and developers just take a guess. The attitude that a problem, if it exists, will be caught by Quality Assurance (QA) or User Acceptance Testing (UAT) is unprofessional at best and incompetence at worst. We want to **know** that what we have just written not only meets our customer’s expectations but also does exactly what we intended for it to do under as many circumstances as we can think of.

> **_Test First allows us to mature from simply testing quality in towards building that quality in from the start_** <small><strong>Jeff Levinson</strong>, Architect at Boeing</small>

Fundamentally it is far cheaper to fix an issue closest to its source. The longer we leave the finding of that defect the more expensive it becomes. A bug found in production is [10 times more costly](http://www.scrum.org/About/All-Articles/articleType/ArticleView/articleId/644/Agile-Economics-The-Dollars-and-Sense-of-Scrum) to fix than the same bug found in development.

The three virtues of Test First:

1. Validation of building what was asked for
2. Validation that what we have built works as we intended
3. Validation that changes have not broken original intent

Ideally, we want our tests to be as close to the code as possible, but also as easily understood by the customer as possible. Ideally, all of our code is automated and we have an executable specification. It’s a balancing act…

### Business Validation – We have built what was asked for

Getting validation that we are building the right thing is key to actually being able to build the right thing. This sounds like a no-brainer but what do we usually do?

Well, we usually take our requirements, in whatever form we generally make them, and give them to our coders to turn into working software. Quite separately we give the same requirements to our testers and they create a bunch of tests to validate what we have built.

Did you notice the problem with this workflow?

> **_The worst that can happen is that we built exactly what the customer asked for!_**

How can we ever build to meet the measure if we don’t build to what is to be measured? We need to flip that on its head and instead have the tests created first (the measure) and then Code to make the tests pass. Now that we have removed the inevitable time-consuming rework we can take that time and use it to create even more value for our customers.

In addition, we are far more likely to be able to meet our customers expectations now we have an additional level of focus provided by those tests.

### Developer Validation – What we have built works as we intended

Its now 2017 and gone are the cowboy days of the late nineties and [early naughties](http://en.wikipedia.org/wiki/Naughties). Along with [using modern source control](https://dev.to/mrhinsh/getting-started-with-a-modern-source-control-system-and-devops-13og-temp-slug-4418693), software engineers can no longer hide behind their management as “not giving the approval to do Unit Testing”, or changing what “unit testing” means to allow them to bypass the requirement. This is [about professionalism](https://nkdagility.com/scrum-tapas-importance-professionalism/) and all developers, no matter what they are working on, should be validating the work that they do.

> **_You are not a professional if you do not do the due diligence necessary to validate what you have created works as intended and continuous to do so.  
> –[Professional Scrum teams build software that works](https://dev.to/mrhinsh/professional-scrum-teams-build-software-that-works-4aie-temp-slug-8239734)_**

There are two main value-adds here. The first is that when a coder creates functionality it does exactly what he intended and we have a record, and executable specification, of what that intent was. The second comes later. When we go to add functionality later we know when we have broken existing functionality and that is one of the most valuable parts of this endeavour.

**Can you imagine how amazing it would be if you could use this executable specification to validate all future changes don’t break your application?**

&nbsp;

### Resources

These resources should help you start down a journey to building better applications:

- [Agile Economics- The Dollars and Sense of Scrum](http://www.scrum.org/About/All-Articles/articleType/ArticleView/articleId/644/Agile-Economics-The-Dollars-and-Sense-of-Scrum "Agile Economics- The Dollars and Sense of Scrum") (Scrum.org)
- [Adopting Test-First Development](http://www.scrum.org/About/All-Articles/articleType/ArticleView/articleId/642/Adopting-Test-First-Development) (Scrum.org)
- [Outside-In Test-Driven Development](http://pluralsight.com/training/courses/TableOfContents?courseName=outside-in-tdd&highlight=mark-seemann_outside-in-tdd-m2-spiking*2!mark-seemann_outside-in-tdd-m1-walking-skeleton*7#outside-in-tdd-m2-spiking) (Pluralsight $)
- [Test First Development – Part 1](http://pluralsight.com/training/courses/TableOfContents?courseName=test-first-development-1&highlight=david-starr_tfd-01-m01-introduction*10,12,13!scott-allen_tfd-writing-unit-tests-i*5,7!david-starr_tfd-01-m06-isolation*11,2#tfd-01-m01-introduction)(Pluralsight $)

## Who is naked Agility Limited – Martin Hinshelwood

[Martin Hinshelwood](https://nkdagility.com/company/about-martin-hinshelwood/) believes that every company deserves high-quality software delivered on a regular cadence that meets its customer’s needs. His goal is to help you reduce your cycle time, improve your time to market, and minimise any organisational friction in achieving your goals. Martin is the [Founder/CEO of naked Agility Limited](https://nkdagility.com) and is both a [Professional Scrum Trainer](https://www.scrum.org/martin-hinshelwood) and a [Microsoft MVP: Visual Studio and Development Technologies](https://mvp.microsoft.com/en-us/PublicProfile/4021815?fullName=Martin%20John%20Hinshelwood). He has been delivering software since 2000 and has been Consulting, Coaching, and Training in DevOps & Agility with Visual Studio, Azure, Team Services, and Scrum since 2010. You can reach Martin on [hello@nkdagility.com](mailto:hello@nkdagility.com?subject=Scrum.org%20Blog%20Post%20Enquiry).


The post [You are doing it wrong if you are not using test first](https://nkdagility.com/you-are-doing-it-wrong-if-you-are-not-using-test-first/) appeared first on [Martin Hinshelwood - naked Agility Ltd](https://nkdagility.com).