I like assertions. They're a really good alternative to unit tests because they can be used in a real environment without the need for maintenance-intensive mocking etc. But assertions have a significant performance cost, especially when they involve consistency checks on large datastructures.
So, a pattern that I've found useful is heavyweight asserts that can be enabled / disabled through external means, in conjunction with high-coverage integration testing. This is really easy in some languages (c/c++, for example, using the preprocessor) and can be more fragile in languages like python (hence the plug above -- which isn't the best way, but is a way, to achieve this 'best of both worlds' testing).
https://github.com/boothby/dissert
I like assertions. They're a really good alternative to unit tests because they can be used in a real environment without the need for maintenance-intensive mocking etc. But assertions have a significant performance cost, especially when they involve consistency checks on large datastructures.
So, a pattern that I've found useful is heavyweight asserts that can be enabled / disabled through external means, in conjunction with high-coverage integration testing. This is really easy in some languages (c/c++, for example, using the preprocessor) and can be more fragile in languages like python (hence the plug above -- which isn't the best way, but is a way, to achieve this 'best of both worlds' testing).