The Green Stage: Making the Tests Pass
Learn how to implement the green stage of the TDD process.
We'll cover the following...
The green stage of the TDD process is the phase that takes place when we already have tests that verify the behavior of the future code. Our goal for this stage is to write the minimal code required to pass the tests. We don’t look for a perfect solution but simply develop the quickest solution possible.
Implementing the green stage
In the playground below, we build an incomplete application to convert MD text into HTML. We have already implemented the red stage of the TDD process and completed tests for that functionality. Now, we must populate the actual application with logic to make our tests pass.
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net7.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> </PropertyGroup> </Project>
Note: The tests in the initial setup are expected to fail because we only have a solution that fulfills the red stage of TDD.
Our scenario is covered by a single test on line 6 of the MdToHtmlConverterTests.cs
file in the MainApp.Tests
project. The test verifies that the code can fulfill the ...