TDD (Test Driven Development) is a much debated word in the tech industry. Debates like Whether you should do TDD or not? or How advantageous is it? are quite popular. Simply said, TDD is test before you develop.

Now, there are a lot of school of thoughts regarding what type of test’s are included and what are not in TDD. As an example, should it include Unit Test, Integration Test, System Test or even UAT?

In this article, we will go through a real-world example on how to write integration tests in .NET 5.0 with TDD methodology.

Project Requirements

TDD requires a very clear understanding of scope of work. Without clarity, all the test cases might not be covered.

Let’s define the scope of work. We will be developing a patient admission system for a Hospital.

Business Requirements

  • A hospital has X ICU rooms, Y Premium rooms & Z General rooms.
  • ICU & Premium rooms can have a single patient at a time, while General rooms can have 2 patients. Each room has a room number.
  • On admitting, the patient has to provide name, age, gender & phone number.
  • It is possible to search a patient via name or phone number.
  • Same patient cannot be admitted to multiple beds while he is still checked in.
  • A patient cannot be admitted if all the rooms are occupied.

#dotnet #testing #tdd #test-driven-development

Learn TDD with Integration Tests in .NET 5.0
2.00 GEEK