covr: Test Coverage for Packages

テストカベレッジ

> library(covr)

バージョン: 2.2.1


関数名 概略
R Run R xxx from within R
RCMD Run R CMD xxx from within R
clear_counters clear all previous counters
codecov Run covr on a package and upload the result to codecov.io
count increment a given counter
coveralls Run covr on a package and upload the result to coveralls
display_name Retrieve the display name from an object
display_name<- Set the display name for an object
environment_coverage calculate the coverage on an environment after evaluating some expressions.
environment_coverage_ calculate the coverage on an environment after evaluating some expressions.
exclusions Exclusions
function_coverage Calculate test coverage for specific function.
key Generate a key for a call
new_counter initialize a new counter
package_coverage Calculate test coverage for a package
path Get/set the PATH variable.
percent_coverage Provide percent coverage of package
print.coverage Print a coverage object
shine Display covr results using a shiny app
subprocess Run R commands in a R subprocess
system_check Run a system command and check if it succeeds.
system_output Run a system command and capture the output.
tally_coverage Tally coverage by line or expression
trace_calls trace each call with a srcref attribute
value Retrieve the value from an object
with_something Execute code in temporarily altered environment.
zero_coverage Provide locations of zero coverage

codecov

テストを実施し、結果をcodecov.ioへ送る

Arguments

  • ...
  • coverage
  • base_url
  • token
  • commit
  • branch
  • quiet
> codecov(path = "test")

function_coverage

特定の関数のカベレッジ

> my_add <- function(x) x + 1
> function_coverage(my_add)
Coverage: 0.00%
<text>: 0.00%

package_coverage

パッケージに含まれるファイルのテストカベレージ

Argumentes

  • path
  • type... tests, vignettes, examples, all, none
  • combine_types
  • relative_path
  • quiet
  • clean
  • line_exclusions
  • function_exclusions
  • code
  • ...
  • exclusions
> package_coverage()
> package_coverage(type = "vignettes")

path

> get_path()
[1] "/usr/bin"            "/bin"                "/usr/sbin"          
[4] "/sbin"               "/usr/local/bin"      "/opt/X11/bin"       
[7] "/Library/TeX/texbin"

shine / report

> x <- package_coverage()
> report(x)