R/reporter-rstudio.R

#' Test reporter: RStudio
#'
#' This reporter is designed for output to RStudio. It produces results in
#' any easily parsed form.
#'
#' @export
#' @family reporters
RStudioReporter <- R6::R6Class("RStudioReporter",
  inherit = Reporter,
  public = list(
    initialize = function(...) {
      self$capabilities$parallel_support <- TRUE
      super$initialize(...)
    },

    add_result = function(context, test, result) {
      if (expectation_success(result)) {
        return()
      }

      loc <- expectation_location(result)
      status <- expectation_type(result)
      first_line <- strsplit(result$message, "\n")[[1]][1]

      self$cat_line(loc, " [", status, "] ", test, ". ", first_line)
    }
  )
)

Try the testthat package in your browser

Any scripts or data that you put into this service are public.

testthat documentation built on Jan. 21, 2022, 1:10 a.m.