News for hackers. Stuff that matters.
Re:Ask HN: What developer tools would you like to see? by jiehong on Sunday May 22, 2022 @08:31AM (#31467418)
Not sure this would be great for new code, because the tests are supposed to dictate the function’s behaviour, and not the other way around.

Yet, this would be amazing for legacy projects with no unit tests: you could record the code in production, and generate unit tests from there, and add them to the non-tested project.

It would bring you a safety net allowing you to better work on that legacy project IMO.

This actually reminds me a an attempt at an internal tool I saw pass by whose goal was to save all IO for a given request (aka db call, log calls, network request, file read) for a given backend, and allow you to replay those locally for testing purposes independently from the language used by the backend. I think this didn’t lead anywhere, because it was harder than expected, some things couldn’t be recorded easily (like RNG use), and it also meant finding a way to have all IO libs use the precomputed values.

Re:Ask HN: What developer tools would you like to see? by danielvaughn on Sunday May 22, 2022 @08:35AM (#31467459)
Very true, yes. Much more useful for existing code. Although I don't think unit tests and TDD necessarily need to be aligned, the red-green-refactor flow could potentially be re-imagined with a tool like this.
Re:Ask HN: What developer tools would you like to see? by adhesive_wombat on Sunday May 22, 2022 @11:21AM (#31469120)
One thing I found useful with Trompeloeil was the tracer. You instantiate a tracer, and then every call made into a mocked object is logged for you. Really make it easy to see how a mysterious controller operates on the thing you are mocking.

Plus, the very act of engineering in a dependency injection for the mock if not already provided, enforces a testable interface.