Golo Roden added "test private methods" a journal written on the subject. This conclusion is particularly me the following notice:
conclusion can yet be said that the problem of testing private developers primarily code is concerned, do not proceed to the TDD . This is not surprising, as TDD-savvy developers to write the test first, and only then the code: Private code can thus only by refactoring of already existing and tested code arise.I develop for a few months himself with TDD (a comprehensive review and how my life has changed by developers in a subsequent post) and am of the opinion that so does the problem with to test private methods automatically. For me this result to 99% for the refactoring step, plus a small example:
is to implement a method that returns me via people ID the full name of a person.
Step 1: Test method
Step 2: Implementation
Step 3: Refactoring
As you can see here, are the private methods developed during the refactoring and now mitgetestet automatically.
I am aware that in this example, the private methods are a bit exaggerated perhaps, I could access it directly in the GetFullName method of the repository on the first and last name. But I wanted to prove that TDD leads to cleaner architecture and private methods are automatically mitgetestet ;-)
0 comments:
Post a Comment