HelloWorld1
HelloWorld1

Reputation: 14108

Unit Testing in Relation to Design Pattern etc

Practitioners of TDD still start with a set of business requirements. The place where TDD deviates from traditional development is the next step. Before you write a single line of code for a feature (including creating a new class to contain that code), you write a unit test based on the current requirement you are working on.

  1. Before you can create a TDD test, do you need to create a a sottware architecture and design pattern before you can initiate TDD?

  2. From my reflection, do you need to define the functionality, the method (private, public) and what return value before you can initiate TDD?


I'm a newbie in unit testing.

Upvotes: 1

Views: 44

Answers (1)

Matthew Strawbridge
Matthew Strawbridge

Reputation: 20610

  1. No. If you need to change the architecture or introduce a design pattern you'd typically do that as part of refactoring. That comes after both the test and the working code.

  2. Of course you could write the test first but it wouldn't compile until there was a minimal framework in place. For example, if you're going to be calling a new method that returns a Boolean then you'd typically write one with a hard-coded return false or return true so your test will compile but fail when you run it. Then you can move on to write the code to make the test pass. Search for red, green, refactor for more details.

  3. I suggest you remove this part of the question. Asking for tool recommendations is off topic. There are plenty of frameworks to choose from and they mostly do a similar thing.

Upvotes: 1

Related Questions