What is Nostr?
Mike Hearn [ARCHIVE] /
npub17ty…qgyd
2023-06-07 02:09:07
in reply to nevent1q…nzz5

Mike Hearn [ARCHIVE] on Nostr: 📅 Original date posted:2011-07-30 🗒️ Summary of this message: Unit tests are ...

📅 Original date posted:2011-07-30
🗒️ Summary of this message: Unit tests are critical for open source projects. Seed the test suite with simple tests and insist on new tests for patches. A manually written test plan is a good start.
📝 Original message:I've worked on open source projects for over 10 years now. This
dynamic always exists but I've never seen it seriously kill a project.

Thoughts:

- People who start out with features often stick around and become
core contributors.
- Unit tests are critical.

Now there's a basic skeleton for unit tests, the bug debt can start to
be paid down by insisting that anyone who touches a piece of code
introduces tests, whether it be for new features or refactorings.
Insist patches won't be accepted without some new tests. In an
untested codebase, adding or improving tests often reveals other bugs
that then get fixed at the same time.

People usually don't want to write tests if there's nothing there
already. So I'd suggest seeding the test suite with a small number of
simple tests for each part (wallet, net, db, etc). Once there are a
few tests already it's easier to get people to add more. It's tempting
to say, well, the wallet or re-org handling or whatever is the most
critical so we'll write lots of tests for that first and do the rest
later, but that's not as conducive to getting people to help.

Most complex projects need some unit testing infrastructure to assist.
For instance, the ability to use mock network connections or minimal
difficulty chains. So if you build up that infrastructure and plant
those seeds, it'll be easier for other people to flesh it out.

Final thought - big test suites take a long time to grow, especially
in codebases developed without them. A good start is a manually
written test plan, that just walks you through the apps features.
Insisting that a patch be signed off as passing the test plan is a
good way to avoid gigantic breakages like the wallet encryption bug
from cold start, at the cost of slowing down development (nobody likes
doing manual test work over and over).

I don't always follow my own advice on this and usually end up
regretting it ....
Author Public Key
npub17ty4mumkv43w8wtt0xsz2jypck0gvw0j8xrcg6tpea25z2nh7meqf4qgyd