2: Advancing your skills
The code should test a specific characteristic or functionality of the package.
Because if your action does too many things at once, you have to search longer for the bug.
Unit testing is a method to communicate to various stakeholders the package requirements.
There are different flavors of unit tests that we write:
Developer Tests
Remove Fear of Change
Reduce Development Time
QA Tests
stats::mean.default
When you are developing new features in a package make sure to prepare the area with unit tests for the expected behavior of the feature.
This will serve two main purposes:
testthat
, tinytest
, box
, Runit
shinytest2
, reactor
, crrry
pointblank
, assertr
, validate
, dataReporter
vdiffr
vdiffr
package allows to save vector graphics file of the expected plot outcomeggplot
sggplot
:
ggplot2::layer_data()
function to extract layer informationcovr
to calculate coveragecovrpage
to create a summary reportWhen developing through a version control platform like GitHub, GitLab, Bitbucket you can automatically run your tests through CI/CD for each commit or when working with other developers via pull requests.