Getting it right: Writing reliable and maintainable R code
summary
Argues that automated tests give quick feedback and let teams change code faster, demonstrates using testthat plus usethis::use_test to scaffold tests and running them with Command/Ctrl‑Shift‑T or devtools::test, shows a real example where unique handling of factors breaks then is fixed and tests updated, explains snapshot testing for Shiny with shinytest record and playback, recommends starting with major functions and integrating tests into CI for continual validation.
AI-written summary · about
chapters (15)
- 0:00Intro
- 0:17Data science through code
- 2:37Code quality matters
- 4:13Writing tests
- 5:55testthat
- 8:14An example of a test file from the string package
- 8:44Expectations
- 11:23Development workflow
- 11:43Testing considerations
- 12:34shinytest
- 15:07Designing for ease of testing
- 16:30Profit!
- 16:49Resources to read/watch
- 17:45Resources for testing packages
- 18:05Next steps
related talks
18mHow non-programmers can make sparks fly when using testthat during package development
18m{shinytest2}: Unit testing for Shiny applications
15mA Robust Framework for Automated Shiny App Testing
29mHow I Learned to Stop Worrying and Love Unit Testing
39mStop Testing, Start Storytelling
37mSensible Testing
32mThinking in tests
46mThe Road to Reliable Automated Tests
