testthat

testthat is a skill for Claude Code, Codex from LeoLin990405/r-analytics-skill. It costs 22 tokens per session (615 once invoked), scanned A, original, MIT.

An R package for writing unit tests, which check small pieces of code independently against expected results.

In plain words
What is it for?
Use it to organise package tests and check values, types, errors, warnings, messages, output, and other conditions.
Why use it?
It catches regressions when code changes and verifies that functions handle normal and incorrect inputs as intended.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to organise package tests and check values, types, errors, warnings, messages, output, and other conditions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/leolin990405/r-analytics-skill/testthat
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add LeoLin990405/r-analytics-skill --skill testthat
Clone the repo
git clone --depth 1 https://github.com/LeoLin990405/r-analytics-skill

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for testthat

README.md
[![agentmods](https://agentmods.dev/badge/skills/leolin990405/r-analytics-skill/testthat/github.svg)](https://agentmods.dev/skills/leolin990405/r-analytics-skill/testthat)
Your own site
<a href="https://agentmods.dev/skills/leolin990405/r-analytics-skill/testthat"><img src="https://agentmods.dev/badge/skills/leolin990405/r-analytics-skill/testthat/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for testthat

Your own site · 80×15
<a href="https://agentmods.dev/skills/leolin990405/r-analytics-skill/testthat"><img src="https://agentmods.dev/badge/skills/leolin990405/r-analytics-skill/testthat.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 22 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 615 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00022 $0.00615
Opus 5 $0.00011 $0.00308
Sonnet 5 $0.00004 $0.00123
Haiku 4.5 $0.00002 $0.00061

Measured 8d ago against content hash 66b806d1b4b5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

testthat scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

sub-skills/r-dev/r-dev-package/testthat/SKILL.md · 141 lines

How it starts

The opening of the file, as written. The whole thing — 141 lines — stays where its author put it; the contents beside it link to each section on GitHub.

testthat

Unit testing for R.

Setup

library(testthat)

# In package development
usethis::use_testthat()

# Creates tests/testthat/ directory

Basic Tests

test_that("description of test", {
  expect_equal(1 + 1, 2)
  expect_true(is.numeric(1))
  expect_false(is.character(1))
})

Expectations

# Equality
expect_equal(x, y)           # Near equality
expect_identical(x, y)       # Exact equality

# Comparison
expect_lt(x, y)              # Less than
expect_lte(x, y)             # Less than or equal
expect_gt(x, y)              # Greater than
expect_gte(x, y)             # Greater than or equal

# Type
expect_type(x, "double")
expect_s3_class(x, "data.frame")
expect_s4_class(x, "Matrix")

# Length/dimension
expect_length(x, 10)

# NULL
expect_null(x)

# Output
expect_output(print(x), "pattern")
expect_message(f(), "message")
expect_warning(f(), "warning")
expect_error(f(), "error")
expect_silent(f())

# Matching
expect_match(x, "regex")

Test Files

# tests/testthat/test-myfunction.R
test_that("myfunction works", {
  result <- myfunction(1, 2)
  expect_equal(result, 3)
})

test_that("myfunction handles errors", {
  expect_error(myfunction("a", "b"))
})

Running Tests

# Run all tests
devtools::test()

# Run specific file
test_file("tests/testthat/test-myfunction.R")

# Run interactively
test_that("quick test", {
  expect_equal(1, 1)
})

Fixtures

# Setup/teardown
test_that("test with setup", {
  # Setup
  tmp <- tempfile()
  write.csv(mtcars, tmp)

  # Test
  data <- read.csv(tmp)
  expect_equal(nrow(data), 32)

  # Cleanup (automatic with withr)
})

# Using withr
test_that("test with withr", {
  withr::local_tempfile(tmp)
  # tmp is cleaned up automatically
})

Skipping

test_that("conditional test", {
  skip_on_cran()
  skip_on_ci()
  skip_if_not_installed("pkg")
  skip_if(condition, "reason")

  # Test code
})

Snapshots

test_that("output matches snapshot", {
  expect_snapshot(print(summary(lm(mpg ~ wt, mtcars))))
})

# Update snapshots
snapshot_accept()

Read the full file on GitHub · 141 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 141 lines · 22 tokens per session scan A 66b806d1b4b5

Subscribe to this mod's changes

testthat is a skill published in the GitHub repository LeoLin990405/r-analytics-skill (5 stars, last pushed 6mo ago), licensed MIT. It adds 22 tokens to every session and 615 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.