diff --git a/DESCRIPTION b/DESCRIPTION index c7ca8a79..f1dbfcdb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,7 +36,7 @@ Suggests: lattice (>= 0.18-4), png, rtables (>= 0.5.1), - testthat (>= 3.0.4), + testthat (>= 3.1.5), tinytex VignetteBuilder: knitr @@ -53,4 +53,4 @@ Encoding: UTF-8 Language: en-US LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.0 diff --git a/inst/WORDLIST b/inst/WORDLIST index 1fdf12fa..07a787dc 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,8 +1,13 @@ Forkers +Hoffmann Prebuilt README Repo catched cloneable +funder +hallal +mahmoud repo rmarkdown +roche diff --git a/man/teal.reporter.Rd b/man/teal.reporter.Rd index 3450bf86..7dc07e96 100644 --- a/man/teal.reporter.Rd +++ b/man/teal.reporter.Rd @@ -2,9 +2,35 @@ % Please edit documentation in R/teal.reporter.R \docType{package} \name{teal.reporter} +\alias{teal.reporter-package} \alias{teal.reporter} \title{Reporting tools for \code{shiny} modules.} \description{ A collection of tools for creating, previewing and modifying reports from \code{shiny} modules. +} +\seealso{ +Useful links: +\itemize{ + \item \url{https://github.com/insightsengineering/teal.reporter} + \item \url{https://insightsengineering.github.io/teal.reporter/} + \item Report bugs at \url{https://github.com/insightsengineering/teal.reporter/issues} +} + +} +\author{ +\strong{Maintainer}: Dawid Kaledkowski \email{dawid.kaledkowski@roche.com} + +Authors: +\itemize{ + \item Maciej Nasinski + \item Konrad Pagacz + \item Mahmoud mahmoud.hallal@roche.com Hallal +} + +Other contributors: +\itemize{ + \item F. Hoffmann-La Roche AG [copyright holder, funder] +} + } \keyword{internal} diff --git a/tests/testthat/test-Archiver.R b/tests/testthat/test-Archiver.R index 5bcaebc5..aeee4498 100644 --- a/tests/testthat/test-Archiver.R +++ b/tests/testthat/test-Archiver.R @@ -20,7 +20,7 @@ reporter <- Reporter$new() reporter$append_cards(list(card1, card2)) testthat::test_that("intialize Archiver", { - expect_error(Archiver$new(), NA) + testthat::expect_no_error(Archiver$new()) }) testthat::test_that("new returns an object of type Archiver", { @@ -34,7 +34,7 @@ testthat::test_that("Archiver errors with the abstract methods", { }) testthat::test_that("intialize FileArchiver", { - testthat::expect_error(FileArchiver$new(), NA) + testthat::expect_no_error(FileArchiver$new()) }) testthat::test_that("FileArchiver creates a temp directory when initialized", { @@ -58,7 +58,7 @@ testthat::test_that("FileArchiver dectructor removes the temp dir", { }) testthat::test_that("intialize JSONArchiver", { - testthat::expect_error(JSONArchiver$new(), NA) + testthat::expect_no_error(JSONArchiver$new()) }) testthat::test_that("JSONArchiver creates a temp directory when initialized", { @@ -79,20 +79,20 @@ testthat::test_that("JSONArchiver dectructor removes the temp dir", { archiver <- JSONArchiver$new() testthat::test_that("JSONArchiver write a reporter", { - testthat::expect_error(archiver$write(reporter), NA) + testthat::expect_no_error(archiver$write(reporter)) }) path_with_files <- archiver$get_output_dir() testthat::test_that("JSONArchiver write a reporter with a json file and static files", { - expect_true(dir.exists(archiver$get_output_dir())) + testthat::expect_true(dir.exists(archiver$get_output_dir())) files <- list.files(archiver$get_output_dir()) testthat::expect_true(length(files) == 4) testthat::expect_true("Report.json" %in% files) }) testthat::test_that("JSONArchiver read back the Reporter instance", { - expect_s3_class(archiver$read(), "Reporter") + testthat::expect_s3_class(archiver$read(), "Reporter") testthat::expect_length(archiver$read()$get_cards(), 2L) testthat::expect_length(archiver$read()$get_blocks(), 8L) }) @@ -109,7 +109,7 @@ testthat::test_that("JSONArchiver read back and all table/picture statics exists archiver2 <- JSONArchiver$new() testthat::test_that("JSONArchiver read back the Reporter instance, from a path", { reporter_temp <- archiver2$read(path_with_files) - expect_s3_class(reporter_temp, "Reporter") + testthat::expect_s3_class(reporter_temp, "Reporter") testthat::expect_length(reporter_temp$get_cards(), 2L) testthat::expect_length(reporter_temp$get_blocks(), 8L) }) diff --git a/tests/testthat/test-ContentBlock.R b/tests/testthat/test-ContentBlock.R index ec74489a..141687e7 100644 --- a/tests/testthat/test-ContentBlock.R +++ b/tests/testthat/test-ContentBlock.R @@ -1,5 +1,5 @@ testthat::test_that("ContentBlock object can be created", { - testthat::expect_error(ContentBlock$new(), regexp = NA) + testthat::expect_no_error(ContentBlock$new()) }) testthat::test_that("new returns an object of type ContentBlock", { @@ -8,7 +8,7 @@ testthat::test_that("new returns an object of type ContentBlock", { testthat::test_that("set_content accepts a character object", { block <- ContentBlock$new() - testthat::expect_error(block$set_content("test"), regexp = NA) + testthat::expect_no_error(block$set_content("test")) }) testthat::test_that("set_content asserts the argument is character", { diff --git a/tests/testthat/test-DownloadReportModule.R b/tests/testthat/test-DownloadReportModule.R index ae90fff7..5c343b30 100644 --- a/tests/testthat/test-DownloadReportModule.R +++ b/tests/testthat/test-DownloadReportModule.R @@ -111,7 +111,7 @@ knitr_args <- list() temp_dir <- tempdir() testthat::test_that("report_render_and_compress - valid arguments", { - testthat::expect_error(report_render_and_compress(reporter, input, knitr_args, temp_dir), NA) + testthat::expect_no_error(report_render_and_compress(reporter, input, knitr_args, temp_dir)) }) testthat::test_that("report_render_and_compress - invalid arguments", { @@ -125,7 +125,7 @@ testthat::test_that("report_render_and_compress - render an html document", { temp_dir <- tempdir() knitr_args <- list() res_path <- report_render_and_compress(reporter, input, knitr_args, temp_dir) - expect_identical(res_path, temp_dir) + testthat::expect_identical(res_path, temp_dir) files <- list.files(temp_dir, recursive = TRUE) testthat::expect_true(any(grepl("[.]Rmd", files))) testthat::expect_true(any(grepl("[.]html", files))) diff --git a/tests/testthat/test-FileBlock.R b/tests/testthat/test-FileBlock.R index 29296fb6..24b07b65 100644 --- a/tests/testthat/test-FileBlock.R +++ b/tests/testthat/test-FileBlock.R @@ -1,5 +1,5 @@ testthat::test_that("FileBlock object can be created", { - testthat::expect_error(FileBlock$new(), regexp = NA) + testthat::expect_no_error(FileBlock$new()) }) testthat::test_that("new returns an object of type FileBlock", { diff --git a/tests/testthat/test-NewpageBlock.R b/tests/testthat/test-NewpageBlock.R index 80c2bc29..b739ff8f 100644 --- a/tests/testthat/test-NewpageBlock.R +++ b/tests/testthat/test-NewpageBlock.R @@ -1,5 +1,5 @@ testthat::test_that("NewpageBlock object can be created", { - testthat::expect_error(NewpageBlock$new(), regexp = NA) + testthat::expect_no_error(NewpageBlock$new()) }) testthat::test_that("new returns an object of type NewpageBlock", { @@ -8,5 +8,5 @@ testthat::test_that("new returns an object of type NewpageBlock", { testthat::test_that("set_content accepts a string", { block <- NewpageBlock$new() - testthat::expect_error(block$get_content(), regexp = NA) + testthat::expect_no_error(block$get_content()) }) diff --git a/tests/testthat/test-PictureBlock.R b/tests/testthat/test-PictureBlock.R index 5d96c846..724a89a3 100644 --- a/tests/testthat/test-PictureBlock.R +++ b/tests/testthat/test-PictureBlock.R @@ -1,8 +1,7 @@ # Constructor testthat::test_that("PictureBlock object can be created", { - testthat::expect_error( - PictureBlock$new(), - regexp = NA + testthat::expect_no_error( + PictureBlock$new() ) }) @@ -13,9 +12,8 @@ testthat::test_that("new returns an object of type PictureBlock", { # set_content testthat::test_that("set_content accepts a plot object", { block <- PictureBlock$new() - testthat::expect_error( - block$set_content(ggplot2::ggplot(iris)), - regexp = NA + testthat::expect_no_error( + block$set_content(ggplot2::ggplot(iris)) ) }) @@ -61,9 +59,8 @@ testthat::test_that("get_content returns character(0) on a newly initialized Pic # set_title testthat::test_that("set_title accepts a string", { - testthat::expect_error( - PictureBlock$new()$set_title("Test"), - NA + testthat::expect_no_error( + PictureBlock$new()$set_title("Test") ) }) @@ -101,9 +98,8 @@ testthat::test_that("get_title returns the set title", { # set_dim testthat::test_that("set_dim accepts an array of two numeric values", { - testthat::expect_error( - PictureBlock$new()$set_dim(c(0, 0)), - regexp = NA + testthat::expect_no_error( + PictureBlock$new()$set_dim(c(0, 0)) ) }) @@ -132,23 +128,20 @@ testthat::test_that("set_content throws if the content is not of the supported t }) testthat::test_that("set_content accepts a `ggplot` object", { - testthat::expect_error( - PictureBlock$new()$set_content(ggplot2::ggplot(iris)), - regexp = NA + testthat::expect_no_error( + PictureBlock$new()$set_content(ggplot2::ggplot(iris)) ) }) testthat::test_that("set_content accepts a `grob` object", { - testthat::expect_error( - PictureBlock$new()$set_content(ggplot2::ggplotGrob(ggplot2::ggplot(iris))), - regexp = NA + testthat::expect_no_error( + PictureBlock$new()$set_content(ggplot2::ggplotGrob(ggplot2::ggplot(iris))) ) }) testthat::test_that("set_content accepts a `trellis` object", { - testthat::expect_error( - PictureBlock$new()$set_content(lattice::bwplot(1)), - regexp = NA + testthat::expect_no_error( + PictureBlock$new()$set_content(lattice::bwplot(1)) ) }) diff --git a/tests/testthat/test-RcodeBlock.R b/tests/testthat/test-RcodeBlock.R index e4a06152..6066d237 100644 --- a/tests/testthat/test-RcodeBlock.R +++ b/tests/testthat/test-RcodeBlock.R @@ -1,5 +1,5 @@ testthat::test_that("RcodeBlock object can be created", { - testthat::expect_error(RcodeBlock$new(), regexp = NA) + testthat::expect_no_error(RcodeBlock$new()) }) testthat::test_that("new returns an object of type RcodeBlock", { @@ -8,7 +8,7 @@ testthat::test_that("new returns an object of type RcodeBlock", { testthat::test_that("set_content accepts a string", { block <- RcodeBlock$new() - testthat::expect_error(block$set_content("test"), regexp = NA) + testthat::expect_no_error(block$set_content("test")) }) testthat::test_that("set_content asserts the argument is a string", { @@ -37,7 +37,7 @@ testthat::test_that("set_params accepts one of the styles returned by get_availa for (param in RcodeBlock$new()$get_available_params()) { input <- list() input[[param]] <- NULL - testthat::expect_error(RcodeBlock$new()$set_params(input), regexp = NA) + testthat::expect_no_error(RcodeBlock$new()$set_params(input)) } }) diff --git a/tests/testthat/test-Renderer.R b/tests/testthat/test-Renderer.R index e5e12aed..139caa06 100644 --- a/tests/testthat/test-Renderer.R +++ b/tests/testthat/test-Renderer.R @@ -1,5 +1,5 @@ testthat::test_that("Renderer object can be created", { - testthat::expect_error(Renderer$new(), regexp = NA) + testthat::expect_no_error(Renderer$new()) }) testthat::test_that("new returns an object of type Renderer", { diff --git a/tests/testthat/test-ReportCard.R b/tests/testthat/test-ReportCard.R index e6e4eb4a..5c0f5a10 100644 --- a/tests/testthat/test-ReportCard.R +++ b/tests/testthat/test-ReportCard.R @@ -1,5 +1,5 @@ testthat::test_that("ReportCard object can be created", { - testthat::expect_error(ReportCard$new(), regexp = NA) + testthat::expect_no_error(ReportCard$new()) }) testthat::test_that("new returns an object of type ReportCard", { @@ -7,7 +7,7 @@ testthat::test_that("new returns an object of type ReportCard", { }) testthat::test_that("append_text accepts a character", { - testthat::expect_error(ReportCard$new()$append_text("test"), regexp = NA) + testthat::expect_no_error(ReportCard$new()$append_text("test")) }) testthat::test_that("append_text returns self", { @@ -16,9 +16,8 @@ testthat::test_that("append_text returns self", { }) testthat::test_that("append_table accepts a data.frame", { - testthat::expect_error( - ReportCard$new()$append_table(iris), - regexp = NA + testthat::expect_no_error( + ReportCard$new()$append_table(iris) ) }) @@ -33,31 +32,27 @@ testthat::test_that("append_plot returns self", { }) testthat::test_that("append_plot accepts a ggplot", { - testthat::expect_error( - ReportCard$new()$append_plot(ggplot2::ggplot(iris)), - regexp = NA + testthat::expect_no_error( + ReportCard$new()$append_plot(ggplot2::ggplot(iris)) ) }) testthat::test_that("append_plot accepts a ggplot with a dim", { - testthat::expect_error( - ReportCard$new()$append_plot(ggplot2::ggplot(iris), c(1000L, 100L)), - regexp = NA + testthat::expect_no_error( + ReportCard$new()$append_plot(ggplot2::ggplot(iris), c(1000L, 100L)) ) }) testthat::test_that("append_rcode accepts a character", { - testthat::expect_error( - ReportCard$new()$append_rcode("x <- 2"), - regexp = NA + testthat::expect_no_error( + ReportCard$new()$append_rcode("x <- 2") ) }) testthat::test_that("append_rcode returns self", { - testthat::expect_error( - ReportCard$new()$append_rcode("x <- 2"), - regexp = NA + testthat::expect_no_error( + ReportCard$new()$append_rcode("x <- 2") ) }) @@ -85,8 +80,8 @@ testthat::test_that("append_metadata returns an object of type ReportCard", { }) testthat::test_that("append_metadata accepts a character key and a character or list value", { - testthat::expect_error(ReportCard$new()$append_metadata("key1", "value1"), regexp = NA) - testthat::expect_error(ReportCard$new()$append_metadata("key1", list("value1")), regexp = NA) + testthat::expect_no_error(ReportCard$new()$append_metadata("key1", "value1")) + testthat::expect_no_error(ReportCard$new()$append_metadata("key1", list("value1"))) }) testthat::test_that("append_metadata throws error if key is not character", { diff --git a/tests/testthat/test-Reporter.R b/tests/testthat/test-Reporter.R index d08699d1..d3b90a62 100644 --- a/tests/testthat/test-Reporter.R +++ b/tests/testthat/test-Reporter.R @@ -1,5 +1,5 @@ testthat::test_that("Reporter object can be created", { - testthat::expect_error(Reporter$new(), regexp = NA) + testthat::expect_no_error(Reporter$new()) }) testthat::test_that("new returns an object of type Reporter", { @@ -28,11 +28,11 @@ reporter <- Reporter$new() reporter$append_cards(list(card1, card2)) testthat::test_that("get_cards returns the same cards which was added to reporter", { - expect_identical(reporter$get_cards(), list(card1, card2)) + testthat::expect_identical(reporter$get_cards(), list(card1, card2)) }) testthat::test_that("get_blocks returns the same blocks which was added to reporter, sep = NULL", { - expect_identical(reporter$get_blocks(sep = NULL), append(card1$get_content(), card2$get_content())) + testthat::expect_identical(reporter$get_blocks(sep = NULL), append(card1$get_content(), card2$get_content())) }) reporter_blocks <- reporter$get_blocks() @@ -40,14 +40,14 @@ reporter_blocks2 <- append(reporter_blocks[1:3], NewpageBlock$new()) reporter_blocks2 <- append(reporter_blocks2, reporter_blocks[5:8]) testthat::test_that("get_blocks by default adds NewpageBlock$new() between cards", { - expect_equal(reporter$get_blocks(), reporter_blocks2) + testthat::expect_equal(reporter$get_blocks(), reporter_blocks2) }) reporter2 <- Reporter$new() testthat::test_that("get_blocks and get_cards return empty list by default", { - expect_identical(reporter2$get_blocks(), list()) - expect_identical(reporter2$get_cards(), list()) + testthat::expect_identical(reporter2$get_blocks(), list()) + testthat::expect_identical(reporter2$get_cards(), list()) }) testthat::test_that("The deep copy constructor copies the content files to new files", { @@ -77,7 +77,7 @@ testthat::test_that("reactive_add_card", { testthat::test_that("append_metadata accept only named list", { reporter <- Reporter$new() - testthat::expect_error(reporter$append_metadata(list(sth = "sth")), NA) + testthat::expect_no_error(reporter$append_metadata(list(sth = "sth"))) testthat::expect_error(reporter$append_metadata("sth"), "'list', not 'character'") testthat::expect_error(reporter$append_metadata(list("sth")), "Must have names") }) @@ -86,18 +86,18 @@ testthat::test_that("append_metadata accept only unique names which could not be reporter <- Reporter$new() testthat::expect_error(reporter$append_metadata(list(sth = "sth", sth = 2)), "but element 2 is duplicated") reporter <- Reporter$new() - testthat::expect_error(reporter$append_metadata(list(sth = "sth")), NA) + testthat::expect_no_error(reporter$append_metadata(list(sth = "sth"))) testthat::expect_error(reporter$append_metadata(list(sth = "sth")), "failed: Must be TRUE") }) testthat::test_that("get_metadata", { reporter <- Reporter$new() - testthat::expect_error(reporter$append_metadata(list(sth = "sth")), NA) + testthat::expect_no_error(reporter$append_metadata(list(sth = "sth"))) testthat::expect_identical(reporter$get_metadata(), list(sth = "sth")) }) testthat::test_that("from_reporter returns identical/equal object from the same reporter", { - expect_identical(reporter, reporter$from_reporter(reporter)) + testthat::expect_identical(reporter, reporter$from_reporter(reporter)) }) reporter1 <- Reporter$new() @@ -105,23 +105,23 @@ reporter1$append_cards(list(card1, card2)) reporter2 <- Reporter$new() testthat::test_that("from_reporter does not return identical/equal object form other reporter", { - expect_false(identical(reporter1, reporter2$from_reporter(reporter1))) + testthat::expect_false(identical(reporter1, reporter2$from_reporter(reporter1))) }) testthat::test_that("from_reporter persists the cards structure", { - expect_identical(reporter1$get_cards(), reporter2$from_reporter(reporter1)$get_cards()) + testthat::expect_identical(reporter1$get_cards(), reporter2$from_reporter(reporter1)$get_cards()) }) testthat::test_that("from_reporter persists the reactive_add_card count", { - expect_identical( + testthat::expect_identical( shiny::isolate(reporter1$get_reactive_add_card()), shiny::isolate(reporter2$from_reporter(reporter1)$get_reactive_add_card()) ) }) testthat::test_that("to_jsondir require the existing directory path", { - expect_error(reporter1$to_list(), 'argument "output_dir" is missing, with no default') - expect_error(reporter1$to_list("/path/WRONG"), "Directory '/path/WRONG' does not exist.") + testthat::expect_error(reporter1$to_list(), 'argument "output_dir" is missing, with no default') + testthat::expect_error(reporter1$to_list("/path/WRONG"), "Directory '/path/WRONG' does not exist.") }) temp_dir <- file.path(tempdir(), "test") @@ -129,18 +129,18 @@ unlink(temp_dir, recursive = TRUE) dir.create(temp_dir) testthat::test_that("to_jsondir returns a list.", { - expect_equal( + testthat::expect_equal( list(version = "1", cards = list(), metadata = list()), Reporter$new()$to_list(temp_dir) ) }) testthat::test_that("to_jsondir and from_jsondir could be used to save and retrive a Reporter ", { - expect_identical( + testthat::expect_identical( length(reporter1$get_cards()), length(Reporter$new()$from_list(reporter1$to_list(temp_dir), temp_dir)$get_cards()) ) - expect_identical( + testthat::expect_identical( length(reporter1$get_blocks()), length(Reporter$new()$from_list(reporter1$to_list(temp_dir), temp_dir)$get_blocks()) ) @@ -148,7 +148,7 @@ testthat::test_that("to_jsondir and from_jsondir could be used to save and retri testthat::test_that("from_reporter returns identical/equal object from the same reporter", { - expect_identical(reporter, reporter$from_reporter(reporter)) + testthat::expect_identical(reporter, reporter$from_reporter(reporter)) }) reporter1 <- Reporter$new() @@ -156,23 +156,23 @@ reporter1$append_cards(list(card1, card2)) reporter2 <- Reporter$new() testthat::test_that("from_reporter does not return identical/equal object form other reporter", { - expect_false(identical(reporter1, reporter2$from_reporter(reporter1))) + testthat::expect_false(identical(reporter1, reporter2$from_reporter(reporter1))) }) testthat::test_that("from_reporter persists the cards structure", { - expect_identical(reporter1$get_cards(), reporter2$from_reporter(reporter1)$get_cards()) + testthat::expect_identical(reporter1$get_cards(), reporter2$from_reporter(reporter1)$get_cards()) }) testthat::test_that("from_reporter persists the reactive_add_card count", { - expect_identical( + testthat::expect_identical( shiny::isolate(reporter1$get_reactive_add_card()), shiny::isolate(reporter2$from_reporter(reporter1)$get_reactive_add_card()) ) }) testthat::test_that("to_jsondir require the existing directory path", { - expect_error(reporter$to_jsondir(), 'argument "output_dir" is missing, with no default') - expect_error(reporter$to_jsondir("/path/WRONG"), "Directory '/path/WRONG' does not exist.") + testthat::expect_error(reporter$to_jsondir(), 'argument "output_dir" is missing, with no default') + testthat::expect_error(reporter$to_jsondir("/path/WRONG"), "Directory '/path/WRONG' does not exist.") }) temp_dir <- file.path(tempdir(), "test") @@ -180,16 +180,16 @@ unlink(temp_dir, recursive = TRUE) dir.create(temp_dir) testthat::test_that("to_jsondir returns the same dir it was provided to it", { - expect_identical(temp_dir, reporter$to_jsondir(temp_dir)) + testthat::expect_identical(temp_dir, reporter$to_jsondir(temp_dir)) }) testthat::test_that("from_jsondir returns identical/equal object", { unlink(list.files(temp_dir), recursive = TRUE) - expect_identical(reporter, reporter$from_jsondir(temp_dir)) + testthat::expect_identical(reporter, reporter$from_jsondir(temp_dir)) }) testthat::test_that("to_jsondir and from_jsondir could be used to save and retrive a Reporter", { reporter_arch <- reporter$from_jsondir(reporter$to_jsondir(temp_dir)) - expect_identical(reporter$get_cards(), reporter_arch$get_cards()) - expect_identical(reporter$get_metadata(), reporter_arch$get_metadata()) + testthat::expect_identical(reporter$get_cards(), reporter_arch$get_cards()) + testthat::expect_identical(reporter$get_metadata(), reporter_arch$get_metadata()) }) diff --git a/tests/testthat/test-TableBlock.R b/tests/testthat/test-TableBlock.R index 17db4465..fe51d90b 100644 --- a/tests/testthat/test-TableBlock.R +++ b/tests/testthat/test-TableBlock.R @@ -1,5 +1,5 @@ testthat::test_that("TableBlock object can be created", { - testthat::expect_error(TableBlock$new(), regexp = NA) + testthat::expect_no_error(TableBlock$new()) }) testthat::test_that("new returns an object of type TableBlock", { @@ -8,7 +8,7 @@ testthat::test_that("new returns an object of type TableBlock", { testthat::test_that("set_content accepts a table object", { block <- TableBlock$new() - testthat::expect_error(block$set_content(iris), regexp = NA) + testthat::expect_no_error(block$set_content(iris)) }) testthat::test_that("set_content asserts the argument is a plot", { @@ -52,7 +52,7 @@ testthat::test_that("from_list after to_list to save and retrive", { testthat::test_that("set_content supports data.frame object", { block <- TableBlock$new() - testthat::expect_error(block$set_content(iris), NA) + testthat::expect_no_error(block$set_content(iris)) }) testthat::test_that("set_content supports rtables object", { @@ -65,5 +65,5 @@ testthat::test_that("set_content supports rtables object", { "range" = diff(range(x)) ) }) - testthat::expect_error(block$set_content(rtables::build_table(l, iris)), NA) + testthat::expect_no_error(block$set_content(rtables::build_table(l, iris))) }) diff --git a/tests/testthat/test-TextBlock.R b/tests/testthat/test-TextBlock.R index 8dbc12aa..faa30b04 100644 --- a/tests/testthat/test-TextBlock.R +++ b/tests/testthat/test-TextBlock.R @@ -1,5 +1,5 @@ testthat::test_that("TextBlock object can be created", { - testthat::expect_error(TextBlock$new(), regexp = NA) + testthat::expect_no_error(TextBlock$new()) }) testthat::test_that("new returns an object of type TextBlock", { @@ -8,7 +8,7 @@ testthat::test_that("new returns an object of type TextBlock", { testthat::test_that("set_content accepts a string", { block <- TextBlock$new() - testthat::expect_error(block$set_content("test"), regexp = NA) + testthat::expect_no_error(block$set_content("test")) }) testthat::test_that("set_content asserts the argument is a string", { @@ -35,7 +35,7 @@ testthat::test_that("get_available_styles returns an array of character", { testthat::test_that("set_style accepts one of the styles returned by get_available_styles", { for (style in TextBlock$new()$get_available_styles()) { - testthat::expect_error(TextBlock$new()$set_style(!!style), regexp = NA) + testthat::expect_no_error(TextBlock$new()$set_style(!!style)) } }) diff --git a/tests/testthat/test-addCardModule.R b/tests/testthat/test-addCardModule.R index 8153b225..4f6c3176 100644 --- a/tests/testthat/test-addCardModule.R +++ b/tests/testthat/test-addCardModule.R @@ -86,7 +86,7 @@ testthat::test_that("add_card_button_srv try the card_fun", { args = list(reporter = Reporter$new(), card_fun = card_fun), expr = { session$setInputs(`add_report_card_button` = 0) - expect_warning(session$setInputs(`add_card_ok` = 0)) + testthat::expect_warning(session$setInputs(`add_card_ok` = 0)) } ) @@ -99,7 +99,7 @@ testthat::test_that("add_card_button_srv try the card_fun", { args = list(reporter = Reporter$new(), card_fun = card_fun), expr = { session$setInputs(`add_report_card_button` = 0) - expect_warning(session$setInputs(`add_card_ok` = 0)) + testthat::expect_warning(session$setInputs(`add_card_ok` = 0)) } ) @@ -112,7 +112,7 @@ testthat::test_that("add_card_button_srv try the card_fun", { args = list(reporter = Reporter$new(), card_fun = card_fun), expr = { session$setInputs(`add_report_card_button` = 0) - expect_warning(session$setInputs(`add_card_ok` = 0)) + testthat::expect_warning(session$setInputs(`add_card_ok` = 0)) } ) }) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index b2c47f7b..a21b8a34 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -14,7 +14,7 @@ testthat::test_that("to_flextable: supported class", { testthat::test_that("to_flextable: unsupported class", { unsupported_data <- list(a = 1, b = 2) - expect_error(to_flextable(unsupported_data), "Unsupported class") + testthat::expect_error(to_flextable(unsupported_data), "Unsupported class") }) testthat::test_that("custom_theme to flextable", { diff --git a/tests/testthat/test-yaml_utils.R b/tests/testthat/test-yaml_utils.R index f337dc0c..ce700ae9 100644 --- a/tests/testthat/test-yaml_utils.R +++ b/tests/testthat/test-yaml_utils.R @@ -13,7 +13,7 @@ testthat::test_that("yaml_quoted does not modify the value of the object", { testthat::test_that("conv_str_logi - accept only a string", { testthat::expect_error(conv_str_logi(2)) - testthat::expect_error(conv_str_logi("string"), NA) + testthat::expect_no_error(conv_str_logi("string")) }) testthat::test_that("conv_str_logi - not influence the regular character", { @@ -47,8 +47,8 @@ testthat::test_that("rmd_outputs - all returned out in the rmarkdown namespace", testthat::test_that("rmd_output_arguments - accepts only string from possible rmarkdown outputs", { testthat::expect_error(rmd_output_arguments("random_text")) - testthat::expect_error(rmd_output_arguments("pdf_document"), NA) - testthat::expect_error(rmd_output_arguments("pdf_document", TRUE), NA) + testthat::expect_no_error(rmd_output_arguments("pdf_document")) + testthat::expect_no_error(rmd_output_arguments("pdf_document", TRUE)) }) testthat::test_that("rmd_output_arguments - returned all pdf_document arguments", { @@ -69,8 +69,8 @@ testthat::test_that("as_yaml_auto - accept a named list (optionally nested)", { testthat::expect_error(as_yaml_auto(list(1))) testthat::expect_error(as_yaml_auto("sth")) - testthat::expect_error(as_yaml_auto(list(author = "", output = list(pdf_document = list(toc = TRUE)))), NA) - testthat::expect_error(as_yaml_auto(list(author = "", output = "pdf_document", toc = TRUE, keep_tex = TRUE)), NA) + testthat::expect_no_error(as_yaml_auto(list(author = "", output = list(pdf_document = list(toc = TRUE))))) + testthat::expect_no_error(as_yaml_auto(list(author = "", output = "pdf_document", toc = TRUE, keep_tex = TRUE))) }) testthat::test_that("as_yaml_auto - works the same as yaml::as.yaml for a nested list when as_header is FALSE", { @@ -132,11 +132,10 @@ testthat::test_that("as_yaml_auto - do not accept multi outputs without the mult }) testthat::test_that("as_yaml_auto - accept multi outputs with the multi_output argument", { - testthat::expect_error( + testthat::expect_no_error( as_yaml_auto(list(author = "", output = "pdf_document", output = "html_document", toc = TRUE, keep_tex = TRUE), silent = TRUE, multi_output = TRUE - ), - NA + ) ) })