# Revit Test Fixtures

> >

- **Type:** Skill
- **Install:** `agentstack add skill-nice3point-revit-skills-revit-test-fixtures`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [Nice3point](https://agentstack.voostack.com/s/nice3point)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [Nice3point](https://github.com/Nice3point)
- **Source:** https://github.com/Nice3point/revit-skills/tree/main/plugins/revit-testing/skills/revit-test-fixtures

## Install

```sh
agentstack add skill-nice3point-revit-skills-revit-test-fixtures
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Revit Test Fixtures

A fixture is everything a test runs against: the document, the services it calls, and the cases it repeats over.
Choosing the wrong one is the usual cause of tests that pass alone but fail together, or that silently test nothing.
Match the situation to one reference below and open only that one.

Two invariants hold across every variant:

1. **Create and close documents on the Revit thread.** Any hook that opens, seeds, or closes a document carries `[HookExecutor]`, and every opened or created document is closed in teardown.
2. **Discovery runs before Revit exists.** TUnit evaluates every data source, constructs the test class, and resolves every injected service during discovery, off the Revit thread — they yield only primitives (numbers, strings, file paths) and never call the Revit API at construction. The test body turns those primitives into Revit objects on the Revit thread.

```csharp
public static string[] DocumentPaths => Directory.EnumerateFiles(directory, "*.rvt").ToArray(); // primitives, off-thread

[After(Test)]
[HookExecutor] // teardown touches Revit, so it runs on the Revit thread
public void CloseDocument()
{
    _document?.Close(false);
}
```

## When to use

- A test needs a document, an injected service, or a repeated set of cases.
- Tests share state and interfere with each other.

## Choose the fixture

Match the required state to one reference and open only that reference.

- [references/seeded-document.md](references/seeded-document.md) — **Load when:** you need a fresh, exact, mutable model that the test authors in code.
- [references/sample-files.md](references/sample-files.md) — **Load when:** a fixed set of installed `.rvt` or `.rfa` sample files supplies the cases through `[MethodDataSource]`.
- [references/parameterized-fixtures.md](references/parameterized-fixtures.md) — **Load when:** one test body must run for several extensions or sample directories through `[InstanceMethodDataSource]` and `[InheritsTests]`.
- [references/dependency-injection.md](references/dependency-injection.md) — **Load when:** the test class receives its service under test from a DI container.
- [references/skipping.md](references/skipping.md) — **Load when:** a sample folder or Revit localization may be absent and the affected test must skip cleanly.

## Selecting a data source

`[Arguments]`, `[MethodDataSource]`, and `[InstanceMethodDataSource]` are basic TUnit data-driven-test features.
This skill only selects them for Revit fixtures and adds the Revit-thread boundary.
For other TUnit approaches, including class, matrix, combined, and custom data sources, read TUnit's [Method Data Sources source](https://raw.githubusercontent.com/thomhurst/TUnit/main/docs/docs/writing-tests/method-data-source.md).

- **`[Arguments]`** — a small fixed set of inline primitive cases. Covered in `revit-testing`.
- **`[MethodDataSource(nameof(Member))]`** — a **static** member whose value is fixed at discovery: a computed set of numbers or a static list of sample paths. See `sample-files`.
- **`[InstanceMethodDataSource(nameof(Member))]`** — an **instance** member whose value depends on constructor state: a base class parameterized by extension or directory, or a set built from injected configuration. See `parameterized-fixtures`.
- **A dependency-injection data-source attribute** — a custom TUnit data source that fills test-class constructor parameters from a DI container. See `dependency-injection`.

## Validation

- [ ] Each test gets isolated state; nothing leaks between tests.
- [ ] Every opened or created document is closed in `[After(Test)]`, and fixture hooks that touch Revit use `[HookExecutor]`.
- [ ] Sample files are opened from a private copy, not in place.
- [ ] A missing sample set or localization skips the test rather than failing it.
- [ ] The data-source attribute matches the member: `[MethodDataSource]` for static, `[InstanceMethodDataSource]` for constructor-dependent.

## Common Pitfalls

| Pitfall                                                | Correct approach                                                                       |
|--------------------------------------------------------|----------------------------------------------------------------------------------------|
| Tests passing alone but failing together               | Give each test its own document or state; do not share mutable fixtures.               |
| A data source that returns a Revit object              | Return primitives or paths; build Revit objects in the test body on the Revit thread.  |
| `[MethodDataSource]` on a constructor-dependent member | Use `[InstanceMethodDataSource]` so the instance (and its configuration) exists first. |
| Opening the sample file in place                       | Copy it to a temporary path and open the copy.                                         |
| Failing when the samples folder is missing             | Return an empty data set (its tests are skipped) or call `Skip.Test(...)`.             |

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [Nice3point](https://github.com/Nice3point)
- **Source:** [Nice3point/revit-skills](https://github.com/Nice3point/revit-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-nice3point-revit-skills-revit-test-fixtures
- Seller: https://agentstack.voostack.com/s/nice3point
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
