[Verse 1] When you write your Rust code, don't forget to check That your functions work the way that you expect Unit tests are small, they test one thing at a time Integration tests make sure your parts combine [Chorus] Test test test, make sure it's blessed Pound sign test above your function's the best Assert equals, assert true, panic when it's wrong Testing patterns keep your code strong Test test test, put bugs to rest Green means go and red means fix the mess [Verse 2] Write your test function with the test attribute Start with given when then, that's the perfect fit Given sets up data, when you call your code Then you check results, that's the testing road [Chorus] Test test test, make sure it's blessed Pound sign test above your function's the best Assert equals, assert true, panic when it's wrong Testing patterns keep your code strong Test test test, put bugs to rest Green means go and red means fix the mess [Bridge] Should panic when you know it's gonna fail Mock your data when you need a testing trail Cargo test will run them all for you Red and green will tell you what to do [Verse 3] Group your tests in modules, keep them organized Setup and teardown, get your data primed Property-based testing when you want to be sure Fuzzing finds the bugs that slip through the door [Chorus] Test test test, make sure it's blessed Pound sign test above your function's the best Assert equals, assert true, panic when it's wrong Testing patterns keep your code strong Test test test, put bugs to rest Green means go and red means fix the mess [Outro] Write the test first, then make it pass Quality code will always last Testing patterns, learn them well Your future self will thank you, I can tell
← Don't Make Me Wait (While Others Stay Awake) | Magic Spells That See You Through →