Testing (aka evaluation) should happen when one knows the routine + outcome you want to evaluate that routine one.
Whether it’s code or improving your singing or learning in school. This generalizes to all of that, IMO
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.
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.
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. It’s a very fast, direct way of programming, with a lot of copy pasting and long parameter lists.
When the code is laid out like that, then I can see where it’s going. I see the repetitions, the edge cases etc. Now it starts to make sense to design the data structures, give declarative names, find the right abstractions. Now I can move forward with tests.