4 Comments

Google codebase is probably among the cleanest I've ever worked in. Surely, it depends a lot of the teams and how "legacy" the code was, but for the most part it held true over the years.

The main reason is the readability check when submitting code, but testing for sure contributed to it. When you follow good testing practices, it kinda forces you to think of a code in a cleaner way too.

One note about "All tests should strive to be hermetic: a test should contain all of the information necessary to set up, execute, and tear down its environment." - I think this should be extended to allow test suites, because that's why they were designed. And I can attest from experience that Google did allow test suites.

Expand full comment
author

Yep, I think that was implicit in the chapters (or maybe even explicit). I guess if a test suite is made up of tests and the tests are hermetic, there's little the chance that the suite itself isn't hermetic.

Expand full comment

Exactly! Tests should still follow the other best practices and stay hermetic, but for things like initiating mocks that are fairly harmless, I find test suites to make the tests more readable.

Expand full comment

Definitely sounds like an nice environment in which to code in!

I feel like the difficult part is actually defining public interfaces *within* your code base, so that you can write tests against those interfaces and the implementation is free to change.

Expand full comment