Reduce Dependency Hell: from testthat to tinytest

[This article was first published on R – Strange Attractors, 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.

XKCD comic about dependency hellFor my handful of followers, you may have noticed something strange. Over the past two days, I released updates to all four of my packages on CRAN. I decided to practice what I preach and actively reduce dependency hell by moving from testhat to tinytest. I have been programming for over 20 years, and continue to realize that reducing dependencies is worth the extra effort for both programmer and end-user. Even though it may require extra work up-front, having fewer dependencies which can seriously impact your own projects’ stability is worth it. This is one of my two serious concerns with the tidyverse in R. The recent, thankfully short-lived, issue with lubridate underscores the problems of dependency hell.

Tinyverse

Recently, I found excellent articulation of this concept at the tinyverse for R. This view is espoused by two developers whom I particularly attempt to emulate: Matt Dowle of data.table and Dirk Eddelbuettel of the Rcpp family of packages. I highly recommend reading some of those essays. While reading myself, I remembered tinytest. I want to make crystal clear that I have no issue with testthat. It is a great package, and it does exactly what it purports to do. However, I want to be more proactive in doing my part to reduce dependencies for my end users, so I switched.

The Switch

It was easier than I expected! The main expect_ations are all there. Converting testthat scripts was as simple as replacing test_that({" with a comment hash and erasing the ending "}). For expact_match, I used expect_true using any and grepl. For expect_length,  I used expect_identical on the length of the string. That was it! I converted a few hundred tests in a matter of an hour or so. Programming to reduce dependency hell is not only worth it, but with intelligent packages like tinytest, easier than you may expect! I should probably add this to my list of R tips. As always, comments and suggestions are welcomed!

The post Reduce Dependency Hell: from testthat to tinytest appeared first on Strange Attractors.

To leave a comment for the author, please follow the link and comment on their blog: R – Strange Attractors.

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.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)