This post describes how R unit tests are organized and managed in asterics using testthat.

## Tests organization

Tests are present in the directory backend/R/tests in separate files starting with test- (this is mandatory for the test to be run). In addition, as a naming convention, each test refers to a single function and is named from this function (for instance, the tests for r_multivariate_dotplot are in the file test-rmultivariatedotplot). They are all based on the testthat package and can be executed with this **R** command line:

test_dir("backend/R/tests")


(if launched from the project root directory)

## Automatic testing at the project startup

Tests are launched at the project startup within **R** with:

tests <- TRUE
source("backend/R/conf_wd.R")


## Tests and branch merging

When a branch is merged,

• either this branch pre-existed before the merging of tests into dev and the merging of the branch has to be done with: 1/ git merging of the branch into dev; 2/ testing everything with a session restart; 3/ systematically correcting failed tests and documentation accordingly directly in dev,
• either this branch was creating after test support has been merged into dev. In this case, tests have to be performed and fixed along with documentation before merging into dev.