> For the complete documentation index, see [llms.txt](https://islamu.gitbook.io/islamu-event/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://islamu.gitbook.io/islamu-event/documentation/readme/contributing/tunit.md).

# TUnit

Run focused project-level tests and choose invariant-oriented evidence for each change.

ISLAMU Event uses **TUnit** as its primary, modern test runner. We prioritize strict test quality over quantity, targeting core business invariants rather than brittle mock assertions.

***

## 1. Focused Developer Loop

During active development, never run full solution-level tests. Build the solution first, then run your target test class using a **TUnit tree-node filter**:

```bash
# 1. Build product code
dotnet build --configuration Release --verbosity quiet

# 2. Run target test class with tree-node filter
dotnet test --project tests/Explore.Application.Tests/Explore.Application.Tests.csproj \
  --configuration Release \
  --treenode-filter "/*/*/*<TestClass>/*"
```

> \[!NOTE] `--treenode-filter` is the native TUnit test selector (\~1.5s execution); VSTest `--filter` syntax is not interchangeable.

***

## 2. Invariant-Breaker Testing Strategy

Author tests that guard real platform invariants:

* **Domain State Machines**: Invalid transitions, capacity limits, and lifecycle events.
* **Tenant Isolation**: Queries that attempt cross-tenant reads or operate without ambient tenant context (see [Multi-Tenancy](/islamu-event/documentation/readme/security-and-identity/multi-tenancy.md)).
* **Security & Fail-Closed Gates**: Unauthenticated write attempts, expired session tokens, or missing [Cerbos PDP](/islamu-event/documentation/readme/security-and-identity/authorization.md) policies.
* **Concurrency & Race Conditions**: Optimistic concurrency tokens during ticket purchases or settings edits.
* **Anti-Resurrection Erasure**: Replaying erased user facts against restored databases (see [Disaster Recovery Invariant](/islamu-event/documentation/readme/security-and-identity/privacy-erasure.md#the-golden-rule-of-disaster-recovery)).

> \[!WARNING] Prohibited in tests:
>
> * Tautological mock mirroring (e.g. asserting `repository.Received(1)` without verifying state).
> * Scraping raw source code or CSS class text.
> * Testing underlying third-party framework behavior (e.g. testing whether EF Core honors cancellation tokens).

***

## 3. Documentation-Only Work

For Markdown or GitBook documentation changes (such as edits in `docs/public/`), do **not** run `dotnet build` or .NET test suites. Verification is strictly scoped to Markdown formatting, link integrity, and schema checks.

***

## Related Guides & Next Steps

* [**Local Development Guide**](/islamu-event/documentation/readme/contributing/local-development.md) — Set up your local developer tools.
* [**Clean Architecture Conventions**](/islamu-event/documentation/readme/contributing/clean-architecture.md) — Architectural layer responsibilities.
* [**Authorization & Access Control**](/islamu-event/documentation/readme/security-and-identity/authorization.md) — Writing authorization tests.
* [**Privacy Erasure & Anti-Resurrection**](/islamu-event/documentation/readme/security-and-identity/privacy-erasure.md) — Testing database restore gates.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://islamu.gitbook.io/islamu-event/documentation/readme/contributing/tunit.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
