llnl/smith/cpp-unit-testing
Claude Code and agent skill by llnl/smith
- community
Checking that the SKILL.md file is still in the repository.
Instructions for creating unit tests for Smith
Install
npx vskill@latest install llnl/smith/cpp-unit-testingSKILL.md
This repo’s unit tests:
- Use GoogleTest (
TEST,TEST_F, etc.). - Live close to the code they cover in a
tests/subdirectory. - Are registered with CTest via the CMake macro
smith_add_tests(...).
Where tests go
Place unit tests next to the component they cover:
src/smith/<component>/tests/(recommended for library code)src/tests/(project-wide smoke/regression tests)
Each tests/ directory should contain:
- One or more
*.cpptest files - A
CMakeLists.txtthat registers those tests withsmith_add_tests
Also ensure the parent component adds the tests subdirectory when tests are enabled:
Writing GoogleTest unit tests
- Include GoogleTest:
#include <gtest/gtest.h> - Prefer fast, deterministic, CPU-only tests by default.
- Use fixtures (
TEST_F) when setup/teardown is shared. - Avoid depending on external files unless the test is explicitly a data-driven/integration test.
Registering tests with smith_add_tests
smith_add_tests creates one test executable per source file and registers it with CTest. The executable/test name is the source basename (e.g., test_state_manager.cpp → test_state_manager).
Minimal tests/CMakeLists.txt template:
Notes:
- Keep test source basenames unique across the project (CMake targets are global).
- Add only the libraries you need to
DEPENDS_ON(the library under test +gtest+ any required Smith/TPL targets).
MPI / OpenMP tests
If a test requires MPI, add the MPI dependency and set NUM_MPI_TASKS:
If a test requires OpenMP, set NUM_OMP_THREADS accordingly.
CUDA-enabled unit tests
If you need a CUDA-enabled unit test, gate it behind SMITH_ENABLE_CUDA and pass USE_CUDA:
Running tests
- Configure with tests enabled:
-DENABLE_TESTS=ON -DSMITH_ENABLE_TESTS=ON - Run all tests:
ctest - Run a single test by name:
ctest -R test_state_manager
Examples in this repo
- Macro definition:
cmake/SmithMacros.cmake - Typical component tests:
src/smith/physics/state/tests/CMakeLists.txt - Project-wide tests:
src/tests/CMakeLists.txt
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/cpp-unit-testing/SKILL.md
Popularity
- Repository stars
- 233
- Repository forks
- 35
- 7-day trend score
- 27
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 22 Jun 2026, 4 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/llnl/smith/cpp-unit-testing)