GithubHelp home page GithubHelp logo

cran / unitizer Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 1.91 MB

:exclamation: This is a read-only mirror of the CRAN R package repository. unitizer — Interactive R Unit Tests. Homepage: https://github.com/brodieG/unitizer Report bugs for this package: https://github.com/brodieG/unitizer/issues

R 100.00%

unitizer's Introduction

unitizeR - Interactive R Unit Tests

R build status Dependencies direct/recursive Project Status: Active – The project has reached a stable, usable state and is being actively developed.

TL;DR

unitizer simplifies creation, review, and debugging of tests in R. It automatically stores R expressions and the values they produce, so explicit expectations are unnecessary. Every test is easy to write with unitizer because testing and using a function are the same. This encourages non-trivial tests that better represent actual usage.

Tests fail when the value associated with an expression changes. In interactive mode you are dropped directly into the failing test environment so you may debug it.

unitizer is on CRAN:

install.packages('unitizer')

It bakes in a lot of contextual help so you can get started without reading all the documentation. Try the demo to get an idea:

library(unitizer)
demo(unitizer)

Or check out the screencast to see unitizer in action.

Why Another Testing Framework?

Automated Test Formalization

Are you tired of the deparse/dput then copy-paste R objects into test file dance, or do you use testthat::expect_equal_to_reference or other snapshot testing a lot?

With unitizer you interactively review your code as you would when typing it at the R prompt. Then, with a single keystroke, you tell unitizer to store the code, and any values, warnings, or errors it produced, thereby creating a formal regression test.

Streamlined Debugging

Do you wish the nature of a test failure was more immediately obvious?

When tests fail, you are shown a proper diff so you can clearly identify how the test failed:

diff example

Do you wish that you could start debugging your failed tests without additional set-up work?

unitizer drops you in the test environment so you can debug why the test failed without further ado:

review example

Fast Test Updates

Do you avoid improvements to your functions because that would require painstakingly updating many tests?

The diffs for the failed tests let you immediately confirm only what you intended changed. Then you can update each test with a single keystroke.

Usage

unitizer stores R expressions and the result of evaluating them so that it can detect code regressions. This is akin to saving test output to a .Rout.save file as documented in Writing R Extensions, except that we’re storing the actual R objects and it is much easier to review them.

To use unitizer:

  • Write test expressions as you would when informally testing code on the command line, and save them to a file (e.g. “my_file_name.R”).
  • Run unitize("my_file_name.R") and follow the prompts.
  • Continue developing your package.
  • Re-run unitize("my_file_name.R"); if any tests fail you will be able to review and debug them in an interactive prompt.

unitizer can run in a non-interactive mode for use with R CMD check.

Documentation

Related Packages

Acknowledgments

Thank you to:

About the Author

Brodie Gaslam is a hobbyist programmer based in the US East Coast.

unitizer's People

Contributors

brodieg avatar

Watchers

 avatar  avatar

Forkers

bhanditz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.