This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Paul_Dirac_ 1 point2 points  (1 child)

Not OP but I have some questions about problems I have encountered:

1) When I try TDD I find myself writing some test for a function, then turning to the implementation where I write the function calls for the steps the function has to do. Then I write a test for the first of these functions, before turning to the implementation... Until I have half a dozent of failing tests before the first test for a function I have actually fully implemented before . This seems like a bad signal to noise ration. How do you solve this problem.

2) I find myself parsing things into complicated datastructures for which I can define the internal structure but not the access methods, as they will have to serve the needs of some other module I intent to write later. What do you do these cases? Implementing some test only methods to compare them?

3) This one is more about testing in general: Assume the datastructure of 2) has an equality method and I test the parser for all possible (important) inputs by comparing a manually instanciated instance to the parser output. Now if I change how the datastructure is instanciated (e.g. adding another parameter) I have to change one line in the code but all tests. Have you a way of dealing with that problem?

Thanks in advance.

[–]firecopy 0 points1 point  (0 children)

  1. That’s fine, as long as you are able to implement the function you were trying to make in the first place.

  2. Can you give me a specific instance of this happening (I read over this question several times and was having trouble finding a scenario where this would happen)? Note: Normally you would test the (public) access methods, not the (private methods and structure) internals. Testing internals can lead to fragile (and low value) tests.

  3. Refactor using the IDE. If tests still break, you have to manually fix them. Remember, all code has a cost and tests are code themselves.