Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • We have a problem with TDD as well, namely, what constitutes "minimum code to pass". I demonstrated to the team this process and they took exception to not just writing what we have already designed - which I can understand. The "minimum" doesn't seem to be defined. If we write a test and have clear plans and designs, why not write that to pass the test? Commented Jan 30, 2019 at 8:20
  • @Lee "minimum code to pass"... well, this might sound a bit dumb, but it's literally what it says. E.g. if you have a test UserCanChangeTheirPassword, then in the test you call the (not yet existing) function to change the password and then you assert that the password is indeed changed. Then you write the function, until you can run the test and it does neither throw exceptions nor have a wrong assert. If at that point you have a reason to add any code, then that reason goes into another test, e.g. UserCantChangePasswordToEmptyString. Commented Jan 30, 2019 at 11:10
  • @Lee Ultimately, your tests will end up being the documentation of what your code does, except it's documentation that checks if it is fulfilled itself, instead of just being ink on paper. Also compare with this question - A method CalculateFactorial that just returns 120 and the test passes. That is the minimum. It's also obviously not what was intended, but that just means you need another test to express what was intended. Commented Jan 30, 2019 at 11:21
  • 1
    @Lee Small steps. The bare minimum may be more than you think when the code rises above trivial. Also the design you do when implementing the whole thing at once may again be less optimal because you make assumptions on how it should be made without having written the tests yet that demonstrate it. Again remember, the code should fail at first. Commented Feb 1, 2019 at 0:22
  • 1
    Also, regression tests are very important. Are they in scope for the team? Commented Feb 1, 2019 at 9:55