Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

elixir
erlang

What is Property-Driven Development?

Rizwan Rasheed

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Introduction

Traditionally, building automated test suites was done after writing the production code. However, under time constraints, such tests are more likely to be omitted with this technique. Test-driven Development (TDD) addresses this issue by requiring developers to write production code only after failing a test case. This process has resulted in increased test coverage and fewer untested lines of code. Property-based testing, a newer approach, seeks to enhance test coverage without increasing the effort required to write test suites proportionately.

Work-flow of Property-Driven Development (PDD)

The property-based development methodology is a natural progression of Test-Driven Development. To define the new requirement:

  1. Create a property that the code must fulfill before writing any production code. 2. Use the QuickCheck tool to identify a counterexample
  2. Write the necessary code to remedy all of the counterexamples found by QuickCheck until you are satisfied that the properties are still valid.

Test-driven development and property-based testing complement one other extremely well, and can amplify many of the advantages of each method when used separately.

When programmers write properties instead of test cases, they focus less on the actual implementation and more on the intended outcomes. Although this assertion may be utilized in traditional testing, we feel it is much more valid in property-based testing as it enhances one of TDD’s well-known advantages: it tests as documentation since properties are more informative and manageable than real test cases.

Advantages

  • PDD reduces the risk of choosing a poor set of test cases to drive development when using TDD alone, or a good set of test cases that turns into a bad one after a change in the code. It is also more likely that the test generator will cover new corner cases introduced in future code changes.

  • PDD encourages a more careful selection of the properties used to describe the code. Using the TDD technique guarantees that the programmer validates if the property being written tests something that is failing and should be fixed, as opposed to creating the properties after production code. In other words, it’s less likely that developers would create trivial properties that always hold, giving them a false sense of confidence about the code they’re supposed to be testing.

RELATED TAGS

elixir
erlang

CONTRIBUTOR

Rizwan Rasheed
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring