Testex
Add tests and assertions in-line in R package examples
Install / Use
/learn @dgkf/TestexREADME
testex test examples <img src="https://user-images.githubusercontent.com/18220321/211960830-8c969bee-8c80-4984-8132-b5993911f179.png" align="right" width="134px"/>
Add tests and assertions in-line in examples
Quick Start
Set up your package to use testex using
testex::use_testex()
and then start adding tests!
#' Hello, World!
#'
#' @examples
#' hello("World")
#' @test "Hello, World!"
#'
#' hello("darkness my old friend")
#' @test grepl("darkness", .)
#'
#' @export
hello <- function(who) {
paste0("Hello, ", who, "!")
}
If you were already using testthat, you'll immediately see a new test
context for testing your examples. And if you aren't using testthat, then
you'll find that your tests are being run with your examples when you run
R CMD check
roxygen2 tags
@test
will check that the result of the last example is identical to your test. You
can use the example output in a function using a ..
#' @examples
#' sum(1:10)
#' @test 55
#' @test is.numeric(.)
@testthat
is similar, but has the added benefit of automatically inserting a . into
testthat::expect_* functions.
#' @examples
#' sum(1:10)
#' @testthat expect_equal(55)
#' @testthat expect_vector(numeric())
Prior Art
roxytestA slightly different approach. Allows tests to be written in-line, but generates test files used directly by a testing framework.
Related Skills
gh-issues
342.5kFetch GitHub issues, spawn sub-agents to implement fixes and open PRs, then monitor and address PR review comments. Usage: /gh-issues [owner/repo] [--label bug] [--limit 5] [--milestone v1.0] [--assignee @me] [--fork user/repo] [--watch] [--interval 5] [--reviews-only] [--cron] [--dry-run] [--model glm-5] [--notify-channel -1002381931352]
node-connect
342.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
prose
342.5kOpenProse VM skill pack. Activate on any `prose` command, .prose files, or OpenProse mentions; orchestrates multi-agent workflows.
frontend-design
85.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
