
We ask the question again, and now we can see that we PASSED so we continue to the next bubble in our photograph. Remember KISS is still in place, so all we have to do is return 42 from the Universe class. At this point, all you have to do is implement the logic behind the question you have asked. Now that we have asked our questions and FAILED, we should give the answer. It follows the Behaviour Driven Development pattern of “ Given a state, When an action is performed, Then it should have an expected result.” Green Public void Given_Universe_When_Person_Asks_Then_It_Should_Equal_42()Īs you can notice, this is more readable to a tester or a client that creates the business logic for us to implement. Or you can go for the Given-When-Then type of tests, like so But keep in mind that if you are able to skip trivial steps then you can certainly do so, at your own risk of course. Meaning that if you try to ask every question at the beginning, you would definitely fail at answering them afterwards.

And for our cycle to be repeated you have to KISS (Keep It Simple Stupid). At this point, all you have to think about is writing a test that FAIL. Translate that in TDD and you get the Red bubble in the photograph.

Redīefore you write any code that solves a problem, you have to ask the right questions. Since TDD is a particularly complex process, we only focused on the Unit testing part and how is that implemented in TDD. In other words, it creates a safety net that serves to keep the coder’s problems/bugs at bay while enabling the coder to refactor like a hurricane. This methodology enables one to improve upon one’s coding capabilities while at the same time to keep one’s sanity in check if something is broken.

We opted for TDD in C# alongside these tools: A year and a half ago we started experimenting with Test Driven Development methodology in our workflow.
