4 ms·
I agree that tests are an insurance against changes. They find regressions and are also lights in the darkness that points to where we have to work on. I'm mov
by pmontra 6y ago
I agree that tests are an insurance against changes. They find regressions and are also lights in the darkness that points to where we have to work on.
I'm moving 3 db fields (let's call them a, b, c) from 3 tables (A, B, C) to a fourth one (D) right now. Adding a, b, c to D is easy, the data migration is also easy (a single update from a CTE coalescing a, b, c from the 3 tables -- the value in a wins over b and over c). And now let's see if anything breaks (it has to.) I run the test suite. Only a dozen errors. Some are where I expected them to happen, some are totally unexpected. There are parts of the code base I forgot about in the last year or never heard about (it's a team of about 5 developers.)
Without tests, no matter the language, typing system, etc any change like that would be a nightmare.
- Eridrus 6y agoNot to downplay tests, but this would be caught by a typing system if all access to DB fields was through an ORM such that all access could be type checked. Not to say that everyone should use an ORM, but this would be a very simple property for a type checker to catch if you let it.
- pmontra 6y agoPossibly, but (simplifying a lot) the actual refactoring involves JSONB fields that store serializations of objects which include those fields plus a yet unknown amount of code that might be using them, etc. And we're ending up redesigning part of the UI because 1) it makes sense and 2) it makes the migration to the new backend simpler. Luckily we're pretty well covered by tests.