News for hackers. Stuff that matters.
Re:I was saved by Test Driven Development by pydry on Sunday February 12, 2023 @05:55AM (#34761862)
>The code I write initially can often be very dumb, repetitive and procedural. I often have to discover and see what the data structures really look like, what the public API looks like, what I leave in code and what I want to be data driven etc.

I do this plenty after writing a new (high level integration) test.

Usually I have a fairly clear idea of what the public API I want should look like before I code. A test that calls that makes a good test. I might tweak it when coding the implementation, but probably not by much. The integration test doesn't care what kind of data structures you use.

>At this stage it makes little to no sense to write tests first. All I need is to see the output, which might change dramatically during development.

I frequently write the test first for this type of code. Where I'm expecting the test to change the output I program it to temporarily overwrite the output with the results of the program, eyeball the result and commit it all together if it's correct.

The self rewriting pattern is especially good for API tests or command line tests - where the output is a blob of JSON or a wall of text.

There are no comments on this comment yet.