Acceptance Test-Driven Development with Shiny
[This article was first published on jakub::sobolewski, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
I’ve created this Shiny project to showcase how I practice Acceptance Test-Driven Development with {shinytest2}. The app is very simple – calculate net income from income and expenses inputs. Even in such a simple example we can see:
- how to start a Shiny project by writing a test first. I’m using {rhino}, but the same method can be used for any Shiny framework you use,
- how to interact with the app from tests in a way that won’t break them often by using {selenider} instead of {shinytest2} snapshots,
- how to evolve your project from the simplest solutioan, to implementing more usable app – here we’re starting with a “forgetful” app, then implementing persistent storage,
- how to cycle between ATDD and TDD – from specifying user’s needs to working on implementation details that are hidden from users,
- how using robust selectors allows us to refactor UI without breaking tests.
💡 The best way to explore the repo is to go commit by commit listed in the README.
See how we can go from a failing test to a working app. I know, it’s a very simple app, but the same process can be applied to any project, no matter how complex it is.
Check it out here: https://github.com/jakubsob/shiny-acceptance-tdd
To leave a comment for the author, please follow the link and comment on their blog: jakub::sobolewski.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.