Reader small image

You're reading from  Pragmatic Test-Driven Development in C# and .NET

Product typeBook
Published inSep 2022
PublisherPackt
ISBN-139781803230191
Edition1st Edition
Right arrow
Author (1)
Adam Tibi
Adam Tibi
author image
Adam Tibi

Adam Tibi is a London-based software consultant with over 22 years of experience in .NET, Python, the Microsoft stack, and Azure. He is experienced in mentoring teams, designing architecture, promoting agile and good software practices, and, of course, writing code. Adam has consulted for blue-chip firms including Shell, Lloyds Bank, Lloyd’s of London, Willis Towers Watson, and for a mix of start-ups. As a consultant who has a heterogeneous portfolio of clients, he has gained a solid understanding of the TDD intricacies, which he has transferred into this book.
Read more about Adam Tibi

Right arrow

The No Interdependency guideline

First, I would like to elevate this from a guideline to a principle. This principle ensures that the unit test does not alter a state permanently; or, in other words, executing a unit test should not persist data. Based on this principle, we have the following rules:

  • Test A shouldn’t affect test B.
  • It doesn’t matter whether test A runs before test B.
  • It doesn’t matter whether we run test A and test B in parallel.

If you think about it, a unit test is creating test doubles and doing its operations in memory, and as soon as it finishes execution, all the changes are lost, except the test report. Nothing is saved in the database, in a file, or anywhere, because these dependencies were all provided as test doubles.

Having this principle in place also ensures that the test runner, such as Test Explorer, can run the tests in parallel and use multi-threading if needed.

Ensuring this principle is a shared responsibility...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Pragmatic Test-Driven Development in C# and .NET
Published in: Sep 2022Publisher: PacktISBN-13: 9781803230191

Author (1)

author image
Adam Tibi

Adam Tibi is a London-based software consultant with over 22 years of experience in .NET, Python, the Microsoft stack, and Azure. He is experienced in mentoring teams, designing architecture, promoting agile and good software practices, and, of course, writing code. Adam has consulted for blue-chip firms including Shell, Lloyds Bank, Lloyd’s of London, Willis Towers Watson, and for a mix of start-ups. As a consultant who has a heterogeneous portfolio of clients, he has gained a solid understanding of the TDD intricacies, which he has transferred into this book.
Read more about Adam Tibi