tests/testthat.R

# determine if tests should be skipped
is_skip <- !identical(Sys.getenv("NOT_CRAN"), "true")

# run tests if needed
if (!is_skip) {
  ## load packages
  library(testthat)
  library(prioritizr)

  ## try to load solver packages
  suppressWarnings(require(gurobi))
  suppressWarnings(require(lpsymphony))
  suppressWarnings(require(Rsymphony))

  ## disable parallel testing
  Sys.unsetenv("R_TESTS")

  ## determine reporter
  if (identical(Sys.getenv("CI"), "true")) {
    reporter <- "progress"
  } else {
    reporter <- testthat::check_reporter()
  }

  ## check tests
  test_check("prioritizr", reporter = reporter)
}
prioritizr/prioritizr documentation built on April 30, 2024, 1:35 a.m.