Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.8%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
A simple package for testing R packages
Basic Info
- Host: GitHub
- Owner: yihui
- Language: R
- Default Branch: master
- Homepage: https://cran.rstudio.com/package=testit
- Size: 108 KB
Statistics
- Stars: 58
- Watchers: 6
- Forks: 12
- Open Issues: 1
- Releases: 8
Topics
Metadata Files
README.md
testit
This package provides two simple functions (30 lines of code in total):
assert(fact, ...): think of it asmessage(fact)+stopifnot(...)test_pkg(package): runs tests with all objects (exported or non-exported) in the package namespace directly available, so no need to use the triple-colonpackage:::namefor non-exported objects
Why?
Because it is tedious to type these commands repeatedly in tests:
``` r message('checking if these numbers are equal...') stopifnot(all.equal(1, 1+1e-10), 10*.1 == 1)
message('checking if a non-exported function works...') stopifnot(is.character(package:::utility_foo(x = 'abcd', y = 1:100))) ```
With the two simple functions above, we type six letters (assert) instead of
sixteen (message + stopifnot), and assert is also a more intuitive
function name for testing purposes (you assert a fact followed by evidence):
``` r assert('These numbers are equal', {
(all.equal(1, 1 + 1e-10))
(10 * .1 == 1)
})
assert('A non-exported function works', { res = utility_foo(x = 'abcd', y = 1:100) (is.character(res)) })
assert('T is TRUE and F is FALSE by default, but can be changed', { (T == TRUE ) (F == FALSE)
T = FALSE (T == FALSE) }) ```
R CMD check
Put the tests under the directory pkg_name/tests/testit/ (where pkg_name is
the root directory of your package), and write a test-all.R under
pkg_name/tests/:
r
library(testit)
test_pkg('pkg_name')
That is all for R CMD check. For package development, it is recommended to use
devtools. In particular,
Ctrl/Cmd + Shift + L in RStudio makes all objects in a package visible to you,
and you can run tests interactively.
Installation
Stable version on CRAN:
r
install.packages('testit')
Development version:
r
remotes::install_github('yihui/testit')
More
How about testthat? Well,
this package is far less sophisticated than testthat. There is nothing fancy
in this package. Please do consider testthat if your tests require more
granularity. I myself do not use testthat because I'm too lazy to learn the
new vocabulary (testthat::expect_xxx). For testit, I do not need to think
if I should use expect_equal, expect_equivalent, or expect_identical; I
just write test conditions in parentheses that are expected to return TRUE.
That is the only single rule to remember.
There is no plan to add new features or reinvent anything in this package. It is an intentionally tiny package.

Although he did not really mean it, Xunzi said something that happens to apply well to unit testing:
不积跬步,无以至千里;不积小流,无以成江海。
This package is free and open source software, licensed under GPL-3.
Owner
- Name: Yihui Xie
- Login: yihui
- Kind: user
- Location: Omaha, NE
- Company: @rstudio @swissre @merck
- Website: https://yihui.org
- Twitter: xieyihui
- Repositories: 115
- Profile: https://github.com/yihui
Freelancer (open source programmer, contractor, blogger, and writer)
GitHub Events
Total
Last Year
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Yihui Xie | x****e@y****e | 151 |
| Christophe Dervieux | c****x@g****m | 6 |
| Will Beasley | w****y@h****m | 1 |
| Tomas Kalibera | k****a | 1 |
| Steven M. Mortimer | r****t@g****m | 1 |
| Jacob Long | j****c@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 7 months ago
All Time
- Total issues: 7
- Total pull requests: 8
- Average time to close issues: 21 days
- Average time to close pull requests: 1 day
- Total issue authors: 7
- Total pull request authors: 5
- Average comments per issue: 2.43
- Average comments per pull request: 0.75
- Merged pull requests: 8
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- cderv (1)
- shrektan (1)
- kadyb (1)
- StevenMMortimer (1)
- jayvdb (1)
- leeper (1)
- tomasruizt (1)
Pull Request Authors
- cderv (4)
- StevenMMortimer (1)
- wibeasley (1)
- jacob-long (1)
- kalibera (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- cran 9,908 last-month
- Total docker downloads: 4,688,740
-
Total dependent packages: 44
(may contain duplicates) -
Total dependent repositories: 235
(may contain duplicates) - Total versions: 21
- Total maintainers: 1
cran.r-project.org: testit
A Simple Package for Testing R Packages
- Homepage: https://github.com/yihui/testit
- Documentation: http://cran.r-project.org/web/packages/testit/testit.pdf
- License: GPL-3
-
Latest release: 0.2.1
published over 12 years ago
Rankings
Maintainers (1)
conda-forge.org: r-testit
- Homepage: https://github.com/yihui/testit
- License: GPL
-
Latest release: 0.7
published over 3 years ago
Rankings
Dependencies
- covr * suggests
- rstudioapi * suggests