All Projects → s-fleck → testthis

s-fleck / testthis

Licence: other
Make testing even more fun with RStudio addins and more

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to testthis

Hr
Easy Access to Uppercase H
Stars: ✭ 56 (+80.65%)
Mutual labels:  rstudio, rstudio-addin
lorem
Generate Lorem Ipsum Text
Stars: ✭ 18 (-41.94%)
Mutual labels:  rstudio, rstudio-addin
ermoji
🤷‍♂️ RStudio Addin to Search and Copy Emoji
Stars: ✭ 26 (-16.13%)
Mutual labels:  rstudio, rstudio-addin
hugo-documentation-theme
📖 Project Docs / Knowledge Base template for Hugo Website Builder. 创建项目文档
Stars: ✭ 101 (+225.81%)
Mutual labels:  rstudio
shinyAppTutorials
a collection of shiny app demonstrations 📊
Stars: ✭ 50 (+61.29%)
Mutual labels:  rstudio
seamonster
Solutions engineering assets for demonstration
Stars: ✭ 19 (-38.71%)
Mutual labels:  rstudio
gm
R Package for Music Score and Audio Generation
Stars: ✭ 116 (+274.19%)
Mutual labels:  rstudio
rscloud
Managing RStudio Cloud spaces with R
Stars: ✭ 19 (-38.71%)
Mutual labels:  rstudio
uiucthemes
RMarkdown Templates for UIUC Theme-Oriented Documents
Stars: ✭ 45 (+45.16%)
Mutual labels:  rstudio
viewtweets
🙈🐵 View tweets (timelines, favorites, searches) in Rstudio 🐵🙈
Stars: ✭ 21 (-32.26%)
Mutual labels:  rstudio
compareWith
RStudio Addins for Enhanced Diff and Merge
Stars: ✭ 52 (+67.74%)
Mutual labels:  rstudio
wowchemy-hugo-themes
🔥 Hugo website builder, Hugo themes & Hugo CMS. No code, easily build with blocks! 创建在线课程,学术简历或初创网站。#OpenScience
Stars: ✭ 6,891 (+22129.03%)
Mutual labels:  rstudio
cmna-pkg
Computational Methods for Numerical Analysis
Stars: ✭ 13 (-58.06%)
Mutual labels:  testthat
colorscale
Create a color scale from a single color
Stars: ✭ 80 (+158.06%)
Mutual labels:  rstudio-addin
armcompanion
Companion materials for the rstudio::conf 2019 Advanced R Markdown workshop
Stars: ✭ 15 (-51.61%)
Mutual labels:  rstudio
rstudio-themes
A collection of themes for RStudio
Stars: ✭ 109 (+251.61%)
Mutual labels:  rstudio
caseconverter
RStudio Addin to convert selected text to lower, upper, snake, and camel cases.
Stars: ✭ 20 (-35.48%)
Mutual labels:  rstudio
raspberrypi-rstudio
RStudio for Raspberry Pi - Docker Build and Runtime Environment
Stars: ✭ 57 (+83.87%)
Mutual labels:  rstudio
big-data-upf
RECSM-UPF Summer School: Social Media and Big Data Research
Stars: ✭ 21 (-32.26%)
Mutual labels:  rstudio
COVIDstats
COVID-19 Statistical Analysis Simulator App using R deployed on shinyapps.io a John Hopkins University COVID count clone and simulator
Stars: ✭ 13 (-58.06%)
Mutual labels:  rstudio

testthis

CRAN status Travis build status Codecov test coverage

testthis makes unit testing in R more comfortable. It is designed to complement the packages testthat, devtools and usethis.

Overview

testthis provides RStudio addins for working with files that contain tests. These can be called like normal R function, but it is also possible to assigned them to hotkeys RStudio (Tools/Modify Keyboard Shortcuts).

  • test_this(): Reloads the package and runs tests associated with the currently open R script file.
  • open_testfile(): Opens the associated test file in an editor window. If the currently open file already is a test file, it opens the associated file in the /R directory. Can be used to jump back and forth between both.

The associated test file for a file R/foo.R is usually /tests/testhat/test_foo.R (or test-foo.R). You can modify this behavior by putting the comment #* @testfile anotherfile anywhere in R/foo.R.

testthis also provides functions for managing tests in subdirectories of tests/testthat:

  • use_testdata() places a single R object in the tests/testhat/testdata directory. It is analogous to usethis::use_data(), except that it saves the object in the .rds format, which is more appropriate for single R objects than .rda or .Rdata (see ?readRDS).

  • use_testdata_raw() creates a script-file in the directory tests/testhat/testdata-raw. The testdata-raw directory should contain all script files used to generate the data in tests/testhat/testdata, analogous to the relationship between /data and /data-raw as recommended by devtools/usethis.

  • find_testdata() and read_testdata() are simple helpers to read files saved with use_testdata().

  • use_test_subdir() and test_subdir() for putting/running tests in subdirectories of tests/testhat/. These tests will not be run on CRAN or by devtools::test(). This is useful for tests that take a long time to execute, or that require external resources (web, databases) that may not always be available.

    test_acceptance(), test_manual() and test_integration() are presets to run tests in the integration_tests, acceptance_tests and manual_tests subdirectories of test/testthat.

Testthis also provides some simple code analysis tools

  • test_coverage() lists all functions of package and shows whether they are mentioned in any test_that() call’s desc argument; e.g. if you have a test file containing test_that("testing that function foo works", <...>), foo() will show up marked as tested. This can be used as a simple todo list for testing, but does not replace a proper test coverage analyzer like covr.
  • test_index() produces an index of all test_that() calls. Supports RStudio Markers when run interactively from within RStudio.

For more details see the function reference

Installation

# Testthis is on CRAN:
install.packages("testthis")

# You can also install the development version from GitHub:
# install.packages("remotes")
remotes::install_github("s-fleck/testthis")

Usage

library(testthis)

RStudio addins (can be assigned to hotkeys):

open_testfile()
## The file `tests/testthat/test_myscript.R` does not exist. 
## You can create it with testthis::test_skeleton().

test_skeleton()
## * Creating `tests/testthat/test_myscript.R`

open_testfile()
## > Opens `tests/testthat/test_myscript.R`

test_this() 
## > Runs tests in `tests/testthat/test_myscript.R`
## > works from the original .R file as well as from the file containing the tests

Code analysis:

test_index()

test-index

test_coverage()

## > Package /data/home/fleck/rpkgs/rotor, Test Coverage: 17.8%
## >
## > exported functions .................... 
## > u fun          
## > + backup       
## > + backup_date  
## > + backup_time  
## > ...

# 'u' stands for 'unit tests', more columns are possible if you use the 
# test_subdir() feature of testthis
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].