Skip to content
Agentmart
Submit a tool

nim-testing

Write and run deterministic Nim tests, including isolated test files, expected-exception checks, multi-configuration builds, and sanitizer integration.

Skill by Vyrnexis

IndexedMIT★ 4
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/vyrnexis-nim-testing

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Write and run deterministic Nim tests, including isolated test files, expected-exception checks, multi-configuration builds, and sanitizer integration. Use when setting up a Nim test suite, testing failure behavior, running tests across debug/release/danger modes, or adding AddressSanitizer support.

Use cases: testing, writing

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/nim-testing

What's inside

Skill name
nim-testing
Description
Write and run deterministic Nim tests, including isolated test files, expected-exception checks, multi-configuration builds, and sanitizer integration. Use when setting up a Nim test suite, testing failure behavior, running tests across debug/release/danger modes, or adding AddressSanitizer support.
License
MIT
Instructions
176 lines in SKILL.md · view on GitHub

Files (3)

  • SKILL.md
  • block_test_pattern.md · references/
  • ci_github_actions.md · references/

SKILL.md (first lines)

# Nim Testing

## Rules

### Use `block`-based tests with `doAssert`

Import `std/assertions`. Use `block` scopes with `doAssert` and `doAssertRaises`:

```nim
import std/assertions

block add_basic:
  doAssert add(1, 2) == 3, "add should sum positive integers"

block greet_empty:
  doAssert greet("") == "hello "

block parse_bad_input:
  doAssertRaises ValueError:
    discard parseThing("")
```

`doAssert` raises `AssertionDefect` on failure. `doAssertRaises` passes only when the requested exception type is raised; otherwise the test exits non-zero.

### Write unambiguous assertions

Use ordinary call syntax and grouped negation inside `doAssert`:

```nim
proc foo(x: int): int = x
proc same(x, y: int): bool = x == y

doAssert foo(1) == 1, "foo should return its argument"
doAssert same(1, 1), "same values should match"
doAssert not (foo(1) < 0), "foo should not return a negative value"
doAssert 4 notin @[1, 2, 3]
```

Avoid command-call syntax in assertions. `doAssert foo 1 == 1` can bind the
comparison to `foo`, and `doAssert same 1, 1` can bind the comma to `doAssert`.

### Project layout

```
project/
  src/
    mylib.nim
  tests/
    config.nims        # shared compiler switches
    tester.nim         # central test runner (auto-discovers t*.nim)
    tbasic.nim
    tedge.nim
    terrors.nim
```

Test files use `t` prefix: `tbasic.nim`, `tedge.nim`, `terrors.nim`, `tintegration.nim`.

### `tests/config.nims`

```nim
switch("path", "$projectdir/../src")
```

The compiler loads this config automatically when compiling files in `tests/`.

### `tests/tester.nim`

```nim
import std/os

proc fatal(msg: string) = quit "FAILURE " & msg

proc exec(cmd: string) =
  echo "Running: ", cmd
  if execShellCmd(cmd) != 0: fatal cmd

let testDir = getCurrentDir() / "tests"
for f in walkFiles(testDir / "t*.nim"):
  let name = f.extractFilename
  if name == "tester.nim":
    discard
  else:
    exec "nim c -r " & quoteShell(testDir / name)

echo "All test files completed."
```

Run from project root: `nim c -r tests/tester.nim`

New test files are auto-discovered — no runner edits needed.

### Shared Test Code

Keep test files self-contained when practical. If setup is repeated, extract domain helpers such as sample builders, temp-file setup, or fixture data.

## Workflow

1. **Set up layout.** Create `src/`, `tests/`, and `tests/config.nims`.
2. **Write test files.** Name files with `t` prefix. Use `block`, `doAssert`, and `doAssertRaises`.
3. **Create the runner.** Add `tests/tester.nim` with the auto-discover pattern.
4. **Run all configurations:**

   ```
   nim c -r tests/tester.nim
   nim c -d:release -r tests/tester.nim
   nim c -d:danger -r tests/tester.nim
   ```

5. **Run with ASan** if the project uses unsafe constructs. See "AddressSanitizer" below.
6. **Set up CI.** See `references/ci_github_actions.md`.

## Multi-configuration testing

| Mode                  | Overflow checks | Stack traces (file:line) |
|-----------------------|-----------------|--------------------------|
| default / `-d:debug`  | Yes             | Full                     |
| `-d:release`          | Yes             | Raising frame only       |
| `-d:danger`           | No              | Raising frame only       |

From Vyrnexis/nim-agent-template, MIT.

More from Vyrnexis/nim-agent-template

Signals

Stars
4
Forks
2
Open issues
0
Last commit (this folder)
Aug 20, 2026 (2 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from Vyrnexis

Cite this page

nim-testing skill. Agent Mart. https://agentmart.dev/skills/vyrnexis-nim-testing (last updated 2026-10-24)