Adding Some Math

Learn more about testing and the TDD test structure.

Next, we need to calculate how much of a project is remaining and the completion rate, and then put them together to determine a projected end date.

The next test is for the project to be able to calculate how much work is remaining.

TDD test structure

We like to take a moment before we write a test to think about what the test needs. The typical test structure has three parts:

  • Given: What data does the test need? This test needs a project, at least one complete task, and at least one incomplete task.

  • When: What action is taking place? We’re calculating the remaining work.

  • Then: What behavior do I need to specify? The work-calculation result.

Happy path test

We also like to think about what could make the happy-path test fail. That’s more helpful once we get the happy-path test in place and then start looking at it critically.

With ...