Testing R Packages

🌐Community
by posit-dev · vlatest · Repository

Automates R package testing workflows, ensuring code quality and reproducibility using posit-dev's best practices.

Install on your platform

We auto-selected Claude Code based on this skill’s supported platforms.

1

Run in terminal (recommended)

terminal
claude mcp add testing-r-packages npx -- -y @trustedskills/testing-r-packages
2

Or manually add to ~/.claude/settings.json

~/.claude/settings.json
{
  "mcpServers": {
    "testing-r-packages": {
      "command": "npx",
      "args": [
        "-y",
        "@trustedskills/testing-r-packages"
      ]
    }
  }
}

Requires Claude Code (claude CLI). Run claude --version to verify your install.

About This Skill

What it does

This skill automates R package testing workflows using the testthat framework, following modern best practices for ensuring code quality and reproducibility. It streamlines the process of setting up tests, organizing test files, and running different levels of tests (micro, mezzo, and macro) within an R package development environment. The skill helps developers write robust and well-documented tests for their R packages.

When to use it

  • When initializing a new R package and wanting to set up testing infrastructure from the start.
  • During R package development to ensure individual functions or components behave as expected.
  • Before submitting an R package for publication, to verify its overall functionality and adherence to coding standards.
  • For behavior-driven development (BDD) workflows using describe() and it() blocks.

Key capabilities

  • Initializes a testthat testing environment with the command usethis::use_testthat(3).
  • Organizes test files mirroring the package's source code structure.
  • Supports helper functions (helper-*.R), setup scripts (setup-*.R), and static data fixtures (fixtures/).
  • Provides both standard test_that() syntax and behavior-driven development (BDD) with describe() and it().
  • Offers different testing scales: micro (interactive), mezzo (single file), and macro (full suite).
  • Includes core expectations for equality, errors, warnings, messages, and pattern matching.

Example prompts

  • "Initialize a testthat environment in my R package."
  • "Create a test file for the 'foofy' function."
  • "Run the full test suite for this R package."

Tips & gotchas

  • This skill is specifically designed for testing R packages using testthat version 3 or higher.
  • Test descriptions should focus on describing expected behavior, not implementation details.
  • Use devtools::load_all() for interactive development and testing of individual components.

Tags

🛡️

TrustedSkills Verification

Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.

Security Audits

Gen Agent Trust HubPass
SocketPass
SnykPass

Details

Version
vlatest
License
Author
posit-dev
Installs
35

🌐 Community

Passed automated security scans.