Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

TDD is being done in weird ways by lots of people from what I've seen. I always understood the book's advice to never write code without a test as both aspirational, and productivity advice, not a hard rule.

My first job predated (at least our knowledge of) TDD and unit test frameworks. We would write little programs that would include some of our code and exercise them a bit during development. Later when everything was working and integrated, we'd throw it away. I believe that used to be called scaffolding (before Rails gave that term a different meaning).

When I got into unit testing and some degree of TDD a while later, I kinda kept the same spirit. The unit tests help me build the thing without needing ten steps to test that it works. Sure, I keep the tests, but primarily as documentation on how the parts of the system that are covered should behave. And when it's significantly easier to test something manually than to write a unit test, I tend towards that.

In languages that have good REPLs, I tend to write fewer tests, cause they function as a universal test scaffold.

Trying to reach 100 % test coverage and using unit tests for QA strikes me as strange. They're at most useful to quickly detect regressions. But most of these monster test suites become a burden over time from my experience. A pragmatic test suite rarely does. There's a lot of potential in having the right balance between unit tests, integration tests and manual testing. There's a lot of time wasted if the balance is off.

With this mindset, I totally write tests for a prototype if it looks like it'll save me time. Not even close to 100 % coverage though.



> I believe that used to be called scaffolding

We always called them "Unit Tests." Same for what we now call Test Harnesses.

Sometime in the last decade or so, "Unit Test" has become a lot more formalized, to mean the code-only structural testing we see, these days.

I tend to like using Test Harnesses[0], which are similar to what you described.

Unit tests are great, but I have found, in my own work, that 100% code coverage is often no guarantee of Quality.

I have yet to find a real "monkey testing" alternative. I suspect that AI may give us that, finally.

Oh, I also do "Discovery Coding," but I call it "Evolutionary Design."[1] I think others call it that, as well.

[0] https://littlegreenviper.com/various/testing-harness-vs-unit...

[1] https://littlegreenviper.com/various/evolutionary-design-spe...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: