Test First Programming

Test First Programming

General pitfalls of traditional programming is that Programmers tend to miss out on certain test cases. As a result, the gaps in requirement surface during dedicated testing done by quality team.

Test First Programming is a programming approach in which the programmers designs all possible test cases against the requirement first. And then goes on to write code against test cases. This way there is very little chance of missing out on the use cases.

Video: Test Driven Development

Origins

Conceptually this approach aligns with the Lean practice of “Build in Quality”. Which in turn proposes to address quality aspects while building the product, rather than think about it during stabilization after build.

However the approach became popular in software development with adaptation on Extreme Programming methodology. Over a period of time, it evolved further into “Test Driven development” (More about it later).

Approach

As mentioned earlier this approach mandates developers to write the exhaustive list of test cases first, before they write even a single line of code. If you think about it otherwise, it is more of a “mindset” than an approach.

The entire process can be summarized into five simple steps:

  1. Write the exhaustive list of test cases
  2. Run all the test cases
  3. Start writing code
  4. At logical checkpoints in your code development, run all test cases
  5. Keep writing code until all test cases pass

You might have pictured by now that as your code incrementally achieves functionality, test cases start passing one by one.

By the end of coding if there are any test cases that still remain FAILING. It is a gentle reminder that your code has not covered all use cases.

Benefits

Some advantages might already be flashing before your mind. Let us look at some of the benefits

  • Improved Quality: Team will begin to notice that there are substantially lesser defects in the system. This is the effect of “Built-in-Quality”
  • Goal driven programming: Developers would start coding against test cases which means they have an objective goal towards which they can march and verify their work
  • Improved Test Coverage: Since the Quality team are not the one people who are thinking in terms of test cases, they have helping hand in covering all possible test paths
  • Comprehensive Unit Testing: Unit testing will be much more thorough since the very first step in programming here is to write test cases. Minor unit tests can be easily aligned with actual test cases written by he developer
  • Holistic Thinking: Making the programmer think like a Tester or Analyst about the test cases before even writing a line of code will set their thought process towards Systems thinking. This will broaden their understanding of the system much more

Test Driven Development (a.k.a TDD)

Test Driven Development (TDD) is an evolution or rather an extension of Test First Programming. the only major difference between them both is “Refactoring”.

That is, TDD = Test First Programming + Refactoring. What exactly do we mean by “Refactoring” here?

In other words, TDD forces the developer to also considers the design of the system when writing test cases and writing code to fulfill those test cases. And how exactly is that achieved?

Red-Green-Refactor

TDD has Red/Green/Refactor attributes for the test cases written. And here is how it is used:

  1. Red: When a Test Case is marked as “Red”, it means that the test case has FAILED
  2. Green: When a Test Case is marked as “Green”, it means that the test case has PASSED
  3. Refactor: This is the missing piece in Test-First-Programming. Here the test case is “Green”, but you kick of a thinking process about how to “improve” your code. How much more can you refine your design, optimize the code and make the program maintainable. This may break your code and possibly FAIL any test case, at which point you will fix it.

This approach ensures quality code apart from quality deliverable.

Conclusion

One significant observation you would see as a Manager is that, it turns around the psyche of the development discipline. Also it forces the team to think about quality much early in the delivery lifecycle. One caveat here is to ensure that the team together reviews the test cases written towards development. Unless the test cases are comprehensive, this approach will not be effective.

pmp

Our PMI® PMP®-Prep Course

If interested in this course, click here

  • Case study based training
  • LIVE instruction 36 Hours
  • Post course guidance
  • Exercise per topic
  • 4 Mock exams for practice
  • WhatsApp group support
acp

Our PMI® ACP®-Prep Course

If interested in this course, click here

  • WhatsApp group support
  • 4 Mock exams for practice
  • Exercise per topic
  • LIVE instruction 20 Hours
  • Post course guidance
  • Case study based training
.

JD (Coach/Instructor/Writer)

JD (a.k.a Janakiram) is a Project Management Coach, Trainer Author and Practitioner @Zaidan Consulting. He comes with around 17+ Years of experience primarily from the Software Industry. He is certified on PMI® PMP®, ACP®, Scrum Alliance CSM and Microsoft Certified Solution Developer on C#.NET. He has also authored the book “Practical Agile for Beginners

.

About Zaidan Consulting

Zaidan Consulting are specialists in Project and Program Management space. Our training offerings include:

  • Project Management Training
  • Agile Training
  • PMI®-ACP® Prep Training
  • PMI®-PMP® Prep Training
  • PMI®-CAPM® Prep Training
  • ScrumStudy™ Authorized Training Partner (A.T.P)

Book a FREE appointment

Or you can contact us @+(91) 7672011471

Or Email us: [email protected]

Test First Programming
Scroll to top