For 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!
[…] post Reduce Dependency Hell: from testthat to tinytest appeared first on Strange […]