Does TDD mean not thinking about class design?

前端 未结 8 1851
生来不讨喜
生来不讨喜 2021-02-06 01:17

I am making a role playing game for fun and attempting to use TDD while developing it. Many of the TDD examples I see focus on creating the test first, then creating objects tha

8条回答
  •  遇见更好的自我
    2021-02-06 02:06

    I think you're missing the point of TDD. TDD is not about writing tests - it's about designing your classes to be testable. This naturally leads to a better design and implementation.

    It sounds like you're doing it backwards.

    Your steps should be:

    1. Design your domain model
    2. Design your classes
    3. Write some tests
    4. Implement some class logic
    5. Refactor your classes to make them more testable where necessary
    6. Repeat Steps 3-5

提交回复
热议问题