File: test-package_coverage.R

package info (click to toggle)
r-cran-covr 3.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 984 kB
  • sloc: javascript: 238; cpp: 54; ansic: 48; xml: 41; sh: 18; makefile: 11
file content (31 lines) | stat: -rw-r--r-- 1,054 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
context("package_coverage")
test_that("package_coverage returns an error if the path does not exist", {
  expect_error(package_coverage("blah"))
})

test_that("package_coverage returns an error if the type is incorrect", {
  expect_error(
    package_coverage("TestPrint", type = "blah"),
    "'arg' should be one of")

  expect_error(package_coverage("TestPrint", type = c("blah", "test")),
    "'arg' should be one of")
})

test_that("package_coverage can return just tests and vignettes", {
  cov <- package_coverage("TestPrint", type = c("tests", "vignettes"), combine_types = FALSE)

  expect_equal(names(cov), c("tests", "vignettes"))
})

test_that("package_coverage with type == 'all' returns test, vignette and example coverage", {
  cov <- package_coverage("TestPrint", type = "all", combine_types = FALSE)

  expect_equal(names(cov), c("tests", "vignettes", "examples"))
})

test_that("package_coverage with type == 'none' runs no test code", {
  cov <- package_coverage("TestS4", type = "none")

  expect_equal(percent_coverage(cov), 0.00)
})