use_testthat()
Tests ๐งช
Initialize test infrastructure
Create test file to match our R/ file
use_test("lib-summary")
Write tests
test_that("lib_summary returns expected results", {
<- lib_summary()
res expect_s3_class(res, "data.frame")
expect_equal(ncol(res), 2)
expect_equal(names(res), c("Library", "n_packages"))
expect_type(res$Library, "character")
expect_type(res$n_packages, "integer")
})
test_that("lib_summary fails appropriately", {
expect_error(lib_summary("foo"), "unused argument")
})
Test and check
test()
check()