{"id":14069111,"url":"https://github.com/s-fleck/testthis","last_synced_at":"2025-07-23T16:36:15.875Z","repository":{"id":56936391,"uuid":"103936050","full_name":"s-fleck/testthis","owner":"s-fleck","description":"Make testing even more fun with RStudio addins and more","archived":false,"fork":false,"pushed_at":"2022-02-15T12:31:48.000Z","size":382,"stargazers_count":33,"open_issues_count":5,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-27T22:16:03.205Z","etag":null,"topics":["r","rstudio","rstudio-addin","rstudio-addins","testing","testthat"],"latest_commit_sha":null,"homepage":"https://s-fleck.github.io/testthis/reference/index.html","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/s-fleck.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-18T12:27:26.000Z","updated_at":"2024-01-02T20:30:50.000Z","dependencies_parsed_at":"2022-08-21T07:20:45.247Z","dependency_job_id":null,"html_url":"https://github.com/s-fleck/testthis","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s-fleck%2Ftestthis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s-fleck%2Ftestthis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s-fleck%2Ftestthis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s-fleck%2Ftestthis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s-fleck","download_url":"https://codeload.github.com/s-fleck/testthis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227692777,"owners_count":17805175,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["r","rstudio","rstudio-addin","rstudio-addins","testing","testthat"],"created_at":"2024-08-13T07:06:36.785Z","updated_at":"2024-12-02T07:50:32.453Z","avatar_url":"https://github.com/s-fleck.png","language":"R","readme":"---\noutput: github_document\n---\n\n# testthis\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](http://www.r-pkg.org/badges/version/testthis)](https://cran.r-project.org/package=testthis)\n[![Travis build status](https://travis-ci.com/s-fleck/testthis.svg?branch=master)](https://travis-ci.com/s-fleck/testthis)\n[![Codecov test coverage](https://codecov.io/gh/s-fleck/testthis/branch/master/graph/badge.svg)](https://codecov.io/gh/s-fleck/testthis?branch=master)\n\u003c!-- badges: end --\u003e\n\n**testthis** makes unit testing in R more comfortable. It is designed to \ncomplement the packages \n[testthat](https://github.com/r-lib/testthat), \n[devtools](https://github.com/r-lib/devtools) and \n[usethis](https://github.com/r-lib/usethis). \n\n\n\n## Overview\n\ntestthis provides RStudio addins for working with files that contain tests. \nThese can be called like normal R function, but it is also possible to \nassigned them to hotkeys RStudio (*Tools/Modify Keyboard Shortcuts*).\n\n* `test_this()`: Reloads the package and runs tests associated with the \n  currently open R script file.\n* `open_testfile()`: Opens the associated test file in an editor window. If the \n  currently open file already is a test file, it opens the associated file in\n  the `/R` directory. Can be used to jump back and forth between both.\n  \nThe *associated test file* for a file `R/foo.R` is usually \n`/tests/testhat/test_foo.R` (or `test-foo.R`). You can modify this behavior by\nputting the comment `#* @testfile anotherfile` anywhere in `R/foo.R`.\n\n\ntestthis also provides functions for managing tests in subdirectories of\n`tests/testthat`:\n\n* `use_testdata()` places a single R object in the `tests/testhat/testdata` \n  directory. It is analogous to `usethis::use_data()`, except that it saves the\n  object in the `.rds` format, which is more appropriate for single R objects\n  than `.rda` or `.Rdata` (see `?readRDS`). \n* `use_testdata_raw()` creates a script-file in the directory \n  `tests/testhat/testdata-raw`. The `testdata-raw` directory should contain all \n  script files used to generate the data in `tests/testhat/testdata`, \n  analogous to the relationship between `/data` and `/data-raw` as recommended\n  by *devtools*/*usethis*. \n* `find_testdata()` and `read_testdata()` are simple helpers to read files\n  saved with `use_testdata()`. \n* `use_test_subdir()` and `test_subdir()` for putting/running tests in \n  subdirectories of `tests/testhat/`. These tests will *not* be run on CRAN or\n  by `devtools::test()`. This is useful for tests that take a long time to\n  execute, or that require external resources (web, databases) that may not \n  always be available. \n  \n  `test_acceptance()`, `test_manual()` and\n  `test_integration()` are presets to run tests in the\n  `integration_tests`, `acceptance_tests` and `manual_tests` subdirectories of\n  `test/testthat`.\n  \n\nTestthis also provides some simple code analysis tools\n\n* `test_coverage()` lists all functions of package and shows whether they\n  are mentioned in any `test_that()` call's desc argument; e.g. if you have\n  a test file containing `test_that(\"testing that function foo works\", \u003c...\u003e)`,\n  `foo()` will show up marked as tested. This can be used as a simple todo list \n  for testing, but does not replace a proper test coverage analyzer like\n  [covr](https://github.com/r-lib/covr).\n* `test_index()` produces an index of all `test_that()` calls. Supports RStudio\n  Markers when run interactively from within RStudio.\n\n\nFor more details see the \n[function reference](https://s-fleck.github.io/testthis/reference/index.html)\n\n\n## Installation\n\n```\n# Testthis is on CRAN:\ninstall.packages(\"testthis\")\n\n# You can also install the development version from GitHub:\n# install.packages(\"remotes\")\nremotes::install_github(\"s-fleck/testthis\")\n```\n\n## Usage\n\n```{r}\nlibrary(testthis)\n```\n\n\nRStudio addins (can be assigned to hotkeys):\n\n```{r, eval = FALSE}\nopen_testfile()\n## The file `tests/testthat/test_myscript.R` does not exist. \n## You can create it with testthis::test_skeleton().\n\ntest_skeleton()\n## * Creating `tests/testthat/test_myscript.R`\n\nopen_testfile()\n## \u003e Opens `tests/testthat/test_myscript.R`\n\ntest_this() \n## \u003e Runs tests in `tests/testthat/test_myscript.R`\n## \u003e works from the original .R file as well as from the file containing the tests\n\n```\n\n\nCode analysis:\n```{r, eval = FALSE}\ntest_index()\n\n```\n![test-index](inst/img/test-index.png)\n\n\n```{r, eval = FALSE}\ntest_coverage()\n\n## \u003e Package /data/home/fleck/rpkgs/rotor, Test Coverage: 17.8%\n## \u003e\n## \u003e exported functions .................... \n## \u003e u fun          \n## \u003e + backup       \n## \u003e + backup_date  \n## \u003e + backup_time  \n## \u003e ...\n\n# 'u' stands for 'unit tests', more columns are possible if you use the \n# test_subdir() feature of testthis\n```\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs-fleck%2Ftestthis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs-fleck%2Ftestthis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs-fleck%2Ftestthis/lists"}