nested-fixture-pattern

nested-fixture-pattern is a skill for Claude Code from t1/tdder. It costs 90 tokens per session (1,959 once invoked), scanned A, original, Apache-2.0.

A Java testing pattern that uses JUnit's nested test classes to describe scenarios with several layers of setup, such as a server, database, and prepared user.

In plain words
What is it for?
Use it for stable scenario trees, shared fixture setup, and running an isolated branch of related tests in an IDE.
Why use it?
It avoids repeating expensive setup and keeps each test focused on the conditions specific to its scenario. JUnit is a testing framework for Java.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: names the AskUserQuestion tool.

Part of the tdder plugin — 15 skills, 2 commands, 6 agents, 1 hook shipped together

Good fit Use it for stable scenario trees, shared fixture setup, and running an isolated branch of related tests in an IDE.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/t1/tdder/nested-fixture-pattern
View source ↗ t1/tdder
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 t1/tdder --skill nested-fixture-pattern
Clone the repo
git clone --depth 1 https://github.com/t1/tdder

Made for: Claude Code.

Or install tdder, the plugin that ships this one along with the rest of its 15 skills, 2 commands, 6 agents, 1 hook.

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 nested-fixture-pattern

README.md
[![agentmods](https://agentmods.dev/badge/skills/t1/tdder/nested-fixture-pattern/github.svg)](https://agentmods.dev/skills/t1/tdder/nested-fixture-pattern)
Your own site
<a href="https://agentmods.dev/skills/t1/tdder/nested-fixture-pattern"><img src="https://agentmods.dev/badge/skills/t1/tdder/nested-fixture-pattern/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 nested-fixture-pattern

Your own site · 80×15
<a href="https://agentmods.dev/skills/t1/tdder/nested-fixture-pattern"><img src="https://agentmods.dev/badge/skills/t1/tdder/nested-fixture-pattern.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 90 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,959 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. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00090 $0.01959
Opus 5.5 $0.00036 $0.00784
Sonnet 5.5 $0.00018 $0.00392
Haiku 4.5 $0.00009 $0.00196

Measured 3mo ago against content hash 607b645963fa, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

nested-fixture-pattern 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 3mo 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.

skills/nested-fixture-pattern/SKILL.md · 224 lines

How it starts

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

Nested Fixture Pattern

A pattern combining JUnit's @Nested classes, @RegisterExtension, and ExtensionContext.Store to build declarative scenario trees where each nesting level adds a scope with fixture-managed data. Tests focus on what's specifically relevant to them; expensive setup/teardown happens once per scope; any subtree runs in isolation.

For background, rationale, and tradeoffs, see the blog post.

When to Use

  • Multiple, layered preconditions: 2+ levels of setup that depend on each other, making setup code complex
  • Expensive shared setup: servers, databases, provisioned users that shouldn't repeat per test
  • Well-understood domain: the scenarios are stable enough that Given... class names can meaningfully describe each level
  • Subtree isolation needed: you want to run any subset of the scenario tree independently in the IDE

When Not to Use

  • Simple tests with flat preconditions: just use @BeforeAll or @BeforeEach
  • Each test method needs different setup: use parameterized tests
  • Fast, isolated unit tests: overhead of fixtures and nesting isn't worth it
  • Precondition hierarchies still in flux: refactoring fixtures is more expensive than flat setup

Suggesting the Pattern

When you detect layered test setup (2+ levels of dependent @BeforeAll/@BeforeEach, or test classes with complex shared state), use AskUserQuestion:

  • Question: "This test has layered preconditions. Want to apply the nested fixture pattern?"
  • Options:
    • "Yes, refactor to nested fixtures" — briefly describe what the fixture tree would look like
    • "No, keep flat setup" — acknowledge the trade-off (simpler structure, more setup duplication)

The Pattern

Each @Nested class is a Given clause. Each @RegisterExtension static field is a fixture that sets up when entering that class and tears down when leaving.

class DocumentSharingScenarioTest {
    @RegisterExtension static ServerFixture server = new ServerFixture();

    @Nested class GivenUserAlice {
        @RegisterExtension static UserFixture alice = server.createUser("alice");

        @Test void seesEmptyDocumentList() {
            then(alice.listDocuments()).isEmpty();
        }

        @Nested class GivenDocument {
            @RegisterExtension static DocumentFixture doc =
                    alice.createDocument("notes.txt", "hello world");

            @Test void isVisibleToAlice() {
                then(alice.getDocument(doc.id()))
                        .hasName("notes.txt")
                        .hasContent("hello world");
            }

            @Nested class GivenSharedWithBob {
                @RegisterExtension static UserFixture bob = server.createUser("bob");
                @RegisterExtension static ShareFixture share =
                        doc.shareTo(bob, Permission.READ);

                @Test void bobCanRead() {
                    then(bob.getDocument(doc.id()))
                            .hasContent("hello world");
                }

                @Test void bobCannotWrite() {
                    assertThatThrownBy(() ->
                            bob.updateDocument(doc.id(), "modified"))
                            .isInstanceOf(ForbiddenException.class);
                }
            }
        }
    }
}

Read the full file on GitHub · 224 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. 3mo ago First seen · 224 lines · 90 tokens per session scan A 607b645963fa

Subscribe to this mod's changes

nested-fixture-pattern is a skill published in the GitHub repository t1/tdder (14 stars, last pushed 2d ago), licensed Apache-2.0. It adds 90 tokens to every session and 1,959 once invoked, about $0.0004 per session on Opus 5.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-08-30.

Related

nested-fixture-pattern compared with skills from other repositories

nested-fixture-pattern next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
nested-fixture-patternt1/tdderSkill142d agoApache-2.0A90Claude Code
Test Scaffold (Laravel/PHPUnit)s977043/river-reviewSkill8todayMITA23Claude Code
Unit Test Scaffold (Python/pytest)s977043/river-reviewSkill8todayMITA19Claude Code
Unit Test Scaffold (TypeScript)s977043/river-reviewSkill8todayMITA23Claude Code
js-qualitymorodomi/dev-crewSkill111d agoMITA48Claude Code
php-qualitymorodomi/dev-crewSkill111d agoMITA56Claude Code
python-qualitymorodomi/dev-crewSkill111d agoMITA47Claude Code