We write the code examples in our example files in runnable functions that return some output. We then add tests that call these functions and verify the output matches expectations.
This gives us a few key benefits:
We can verify that the code examples compile and run.
We can verify that the code examples produce the expected output every time they run.
We can verify that the code examples are up-to-date with the latest APIs and that they reflect any product changes over time.
The specifics of how we test the examples varies by interface and language. Select your interface and language for specific details.