Help for Writing Unit Tests Based on Function Examples

Take the examples written in your documentation of functions and use them to create shells (skeletons which must be manually completed by the user) of test files to be tested with the 'testthat' package. Sort of like python 'doctests' for R.


News

exampletestr 1.4.1

BUG FIXES

  • Some calls to tempdir() needed to be tempdir(check = TRUE).
    • This necessitates a dependency on R >= 3.5.0 (this is when the check option appeared in tempdir()).

exampletestr 1.4.0

NEW FEATURES

MINOR IMPROVEMENTS

  • Better messages and warnings, in the style of the usethis package.

BUG FIXES

  • Now depending appropriately on usethis instead of relying on devtools for things that are now implemented in usethis.

exampletestr 1.3.1

BUG FIXES

  • Enforce bug-fixed new verisons of styler and filesstrings.

exampletestr 1.3.0

NEW FEATURES

  • The naming of created files is now less likely to cause conflicts. Now each file created ends with "examples".
  • There's a new function make_test_shell_fun() for making test shells one function at a time. This is thanks to a suggestion by Lorenz Walthert: https://github.com/rorynolan/exampletestr/issues/6.
  • Created files are now optionally opened in the editor when they are created.
  • The use of file paths is now more stable thanks to the rprojroot package.

exampletestr 1.2.0

NEW FEATURES

  • exampletestr now names its test files in the same way as usethis::use_test().

exampletestr 1.1.1

BUG FIXES

  • The new R doesn't like it when the working directory is changed by running examples. This required a fix which this patch provides.

exampletestr 1.1.0

MINOR IMPROVEMENTS

  • Add testthat::context() to test shells.
  • Update for filesstrings v2.0.0.

BUG FIXES

  • Fix issues with open text connections.

exampletestr 1.0.1

BUG FIXES

  • The CITATION is now correct.

exampletestr 1.0.0

  • The package has now passed peer review.

exampletestr 0.5.0

MINOR IMPROVEMENTS

  • Minor documentation improvement.
  • There's no longer an error telling you to run usethis::use_testthat(), now this is just done for you.

exampletestr 0.4.2

MINOR IMPROVEMENTS

  • Add explicit LICENSE file to github.
  • Publish to Wellcome Open Research.

exampletestr 0.4.1

BUG FIXES

  • Fix to an error in DESCRIPTION.

MINOR IMPROVEMENTS

  • Minor documentation improvement.

exampletestr 0.4.0

NEW FEATURES

  • There is now the option to not put stuff in expect_equal() statements by default.

MINOR IMPROVEMENTS

  • The package now uses .Rd files to read the examples rather than roxygen2 tags.
  • Comments in examples are handled better.

exampletestr 0.3.1

BUG FIXES

  • Minor fix to vignette.

exampletestr 0.3.0

  • First CRAN-worthy version.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("exampletestr")

1.5.1 by Rory Nolan, 14 days ago


https://rorynolan.github.io/exampletestr, https://github.com/rorynolan/exampletestr#readme


Report a bug at https://www.github.com/rorynolan/exampletestr/issues


Browse source code at https://github.com/cran/exampletestr


Authors: Rory Nolan [aut, cre] , Sergi Padilla-Parra [ths] , Thomas Quinn [rev] , Laurent Gatto [rev]


Documentation:   PDF Manual  


GPL-3 license


Imports checkmate, filesstrings, fs, glue, magrittr, ore, purrr, readr, rlang, roxygen2, stringr, styler, usethis, withr

Suggests covr, crayon, knitr, pacman, rmarkdown, spelling, testthat


See at CRAN