Skip to content
Back to skills

Performance Testing

ASecurity

Mandatory conventions for authoring .NET 10 performance / load tests for the application's HTTP services with NBomber, living under tests/performance/. In this project, "performance testing" = load/throughput/latency tests over the deployed HTTP services (via the gateway or a service directly), pass/fail-gated against per-endpoint SLOs. Trigger words include performance test, performance tests, load test, load tests, stress test, soak test, spike test, throughput test, latency test, p95, p99,...

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 4, 2026
developmentgobashnodetestinggitapibackendperformance

Works with

  • cli
  • api

Security analysis

A100/100

Scanned December 4, 2026

npx -y skills add elhajahmadj/SDLCskill --skill performance-testing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Performance Testing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Performance Testing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/elhajahmadj-performance-testing/badge)](https://www.skillsdirectory.com/skills/elhajahmadj-performance-testing)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: performance-testing
description: Mandatory conventions for authoring .NET 10 performance / load tests for the application's HTTP services with NBomber, living under tests/performance/. In this project, "performance testing" = load/throughput/latency tests over the deployed HTTP services (via the gateway or a service directly), pass/fail-gated against per-endpoint SLOs. Trigger words include performance test, performance tests, load test, load tests, stress test, soak test, spike test, throughput test, latency test, p95, p99, SLO, SLA, NBomber, benchmark, scalability test, capacity test, scaffold performance test project, add a load scenario, add a perf scenario, run the performance tests.
---

# Performance / Load Tests — Mandatory Conventions

> **In this project, "performance tests" = load/throughput/latency tests** run with **NBomber** against the
> deployed HTTP services (a single service directly, or the gateway end-to-end). They live at
> **`tests/performance/`** — a separate solution (`App.Performance.sln`), never part of `App.sln` or the
> functional/integration suites. Each scenario is **pass/fail**: it asserts measured latency/throughput/
> error-rate against a per-endpoint **SLO** from central config, so a regression fails CI rather than
> printing numbers nobody reads. This file is the rulebook enforced on every change to that suite.

This skill guarantees performance tests follow one architecture, config model, naming, SLO model, and
pinned versions, respecting **SOLID / DRY / YAGNI / clean architecture**, with shared framework code kept
strictly separate from service-specific scenario code. Treat it as **mandatory** whenever it applies.

## When this skill applies

Use for performance / load automation work: add a load scenario · add a new **service** performance
project · scaffold the performance suite · define or change an SLO/threshold · add a load profile
(smoke/load/stress/spike/soak) · create a throughput or latency scenario · run the performance tests (§14).

**Do NOT apply for:** API/integration correctness tests (`api-testing`, `tests/integration/`) · UI/Playwright
functional tests (`functional-testing`, `tests/functional/`) · backend unit tests (`backend-unit-tests`) ·
production application code. Micro-benchmarks of a hot in-process code path are a **separate track**
(BenchmarkDotNet) — see §15; this skill is over-the-wire load, not micro-benchmarks.

## Core principles — enforce on every change

**SOLID** — one reason to change per class; service-specific scenario logic stays out of `Shared`/
`Infrastructure`. **DRY** — exactly one of each: config-loading pipeline · HTTP client factory · load-profile
factory · SLO/threshold model · scenario base · NBomber runner wrapper · stats→assertion helper. **YAGNI** —
no custom reporting engines, no bespoke metrics store, no distributed-agent orchestration unless explicitly
requested. **Clean architecture:**
- `App.Performance.Shared` = config models + loading, SLO/threshold models, validation — **no NBomber**.
- `App.Performance.Infrastructure` = NBomber runner wrapper, HTTP client factory, auth helper, load-profile
  factory, stats→SLO assertion — **the only project that references NBomber**.
- `App.<Service>.PerformanceTests` = per-service scenarios, endpoint constants, traits — no framework code.

## Required layout (follow exactly)

```text
tests/performance/
├── App.Performance.sln
├── appsettings.json            # central config for ALL services: BaseUrls, load profiles, per-endpoint SLOs
├── appsettings.Local.json      # per-developer / per-environment overrides (git-ignored values, no secrets)
├── Directory.Packages.props    # Central Package Management: every version pinned once
├── Directory.Build.targets     # links the central config into each perf project's output
├── README.md
├── App.Performance.Shared/            # class lib, NO NBomber
│   └── Configuration/  (PerformanceConfig, PerformanceConfigLoader, ServiceTarget, LoadProfileOptions, SloOptions)
├── App.Performance.Infrastructure/    # class lib, owns NBomber + HTTP + assertions
│   ├── Http/  (PerformanceHttpClientFactory)
│   ├── Load/  (LoadProfiles — smoke/load/stress/spike/soak → NBomber LoadSimulation[])
│   ├── Auth/  (PerformanceAuthHelper — mints a bearer once, reused across the run)
│   ├── Runner/  (PerformanceTestBase — builds+runs an NBomber scenario, returns stats)
│   └── Assertions/  (SloAssert — asserts NodeStats vs the endpoint SLO; throws to fail the test)
└── Scenarios/                          # grouping folder = the perf dimension (service)
    ├── App.Identity.PerformanceTests/
    │   ├── Constants/  (PerfEndpoints.cs, TraitNames.cs)
    │   └── Scenarios/  (<Feature>Scenarios.cs)
    └── App.<Service>.PerformanceTests/
```

Reference chain, **one way only**:
`App.<Service>.PerformanceTests → App.Performance.Infrastructure → App.Performance.Shared`.
Service projects never reference each other; `Shared` never references `Infrastructure` or NBomber.

---

## Mandatory rules — enforce on every change

### 1. Central Package Management — no inline versions
`tests/performance/Directory.Packages.props` sets `ManagePackageVersionsCentrally=true`. A `PackageReference`
that also carries `Version=` is **NU1008** and fails restore — every csproj is bare. Pin (do not float/wildcard):
`NBomber`, `NBomber.Http`, `Microsoft.NET.Test.Sdk`, `xunit`, `xunit.runner.visualstudio`, `FluentAssertions`
(**never above 7.2.0** — 8.x is commercial), `coverlet.collector`, `Microsoft.Extensions.*` (match/exceed the
app's transitive graph, else **NU1605**). TFM `net10.0`. New package → add a `<PackageVersion>` centrally.
**Confirm the NBomber version restores on first `dotnet restore`** and adjust the pin if needed (record it here).

### 2. xUnit-hosted scenarios (pass/fail, not a console dump)
Every scenario is an xUnit `[Fact]` (so `dotnet test` runs it and CI gates on it), **not** a `Main()` console
dump. The test builds an NBomber `ScenarioProps`, runs it via `PerformanceTestBase`, and **asserts** the
resulting `NodeStats` against the endpoint SLO with `SloAssert`. A scenario with no assertion is incomplete —
printing latency numbers is not a test. NBomber's own HTML/txt report is a side artifact, never the pass signal.

### 3. Configuration — one centralized file (no per-project appsettings)
Exactly one config pair at `tests/performance/` (`appsettings.json` + `appsettings.Local.json`), linked into
each project's output by `Directory.Build.targets` (gated on `IsTestProject`). It carries: per-service
`BaseUrl` (under a `Services` section, same keys as the integration suite: Identity/Orders/Messaging/Payments/
Notifications/Catalog/Gateway), named **load profiles** (`Smoke`/`Load`/`Stress`/`Spike`/`Soak` → rate +
duration), and per-endpoint **SLOs**. Loaded through `PerformanceConfigLoader` only — no ad-hoc
`ConfigurationBuilder`, no hardcoded URLs. Required keys validated at load with a message naming the missing
key. **Secrets are never committed** — auth values come from env vars with a `PERF_`-prefixed name distinct
from the app's and the integration suite's.

### 4. SLOs are explicit, per endpoint, and the pass/fail bar (mandatory)
Every scenario asserts against an **SLO** (service-level objective) resolved from config, never an inline
literal. The SLO minimally sets: **p95 latency (ms)**, optionally **p99**, **max error-rate (%)**, and an
optional **min throughput (req/s)**. `SloAssert` fails the test if p95 > target, error-rate > target, or
throughput < min. Choosing an SLO is part of the task — a scenario without a documented SLO in
`docs/tests.md` (Performance section) is not done. Never assert "it didn't crash"; assert the numbers.

### 5. Load profiles are named + shared (no inline injection rates)
Injection shapes live in `LoadProfiles` (Infrastructure), parameterized from config, one per kind:
- **Smoke** — a few req/s for a short window (CI-safe; the default that runs on every PR).
- **Load** — expected peak sustained.
- **Stress** — ramp beyond peak to find the knee.
- **Spike** — sudden surge then drop.
- **Soak** — moderate rate for a long window (leak/degradation detection).
A scenario picks a profile by name; it never hand-rolls `Simulation.Inject(...)` inline. **CI runs Smoke only**
by default (short, deterministic); Load/Stress/Spike/Soak run on demand / scheduled against a dedicated
environment (they are not gated on every PR — they are noisy and long).

### 6. Scenario naming (mandatory)
```
<Feature>_<Endpoint>_<Profile>_Meets<Slo>    e.g.  Auth_Login_Smoke_MeetsLatencySlo
```
xUnit method: `[Fact]` name `Given<Load>_When<Endpoint>_Then_MeetsSlo` is also acceptable, but the scenario
**name string** passed to NBomber must be stable and unique (it keys the report + the SLO lookup). Business
terms, not NBomber/HTTP jargon. No ticket ids in names.

### 7. Trait rules (mandatory)
Every `[Fact]` has ≥1 trait from `Constants/TraitNames.cs` (`Category` + nested consts:
`Performance`, `Smoke`, `Load`, `Stress`, `Spike`, `Soak`, `Latency`, `Throughput`). No inline magic trait
strings. CI filters `Category=Smoke` for the per-PR gate; the heavier profiles are filtered in for scheduled runs.

### 8. Isolation, warmup, determinism
- **Warm up** before measuring (NBomber `WithWarmUpDuration`) so JIT/connection-pool/first-request cost doesn't
  pollute the SLO — never assert on a cold run.
- One scenario asserts **one endpoint/flow**; don't blend unrelated endpoints in one measured scenario.
- No `Thread.Sleep`/wall-clock waits in scenario code; use NBomber timing.
- Reuse **one** `HttpClient` per scenario from the factory (a client-per-request skews results and exhausts
  sockets). Mint any auth token **once** (`PerformanceAuthHelper`), reuse it across the run.
- Perf runs need the target **actually deployed** and a **quiet environment** — never run load against a box
  someone is demoing on, and never against production without explicit sign-off.

### 9. Secrets & safety
No secrets committed (env vars, `PERF_`-prefixed). Never point a Stress/Spike/Soak profile at production or a
shared dev box without explicit authorization — load tooling is a DoS if pointed at the wrong target. Default
`BaseUrl`s are localhost; overriding to a shared environment is a deliberate, reviewed act.

### 10. Framework unit-test coverage
Any change to `App.Performance.{Shared,Infrastructure}` (config loader, `LoadProfiles`, `SloAssert`, the HTTP
factory, guards) must be matched by an added/updated hermetic unit test **or** the gap documented. `SloAssert`
and the config loader are pure logic and MUST be unit-tested (feed synthetic stats → assert pass/fail).

---

## Forbidden patterns (reject in review)
Service scenario logic in `Shared`/`Infrastructure`; a service project referencing another; `Shared`→NBomber;
a scenario with no SLO assertion ("ran, didn't crash"); an inline injection rate or inline SLO literal;
inline trait strings; a hardcoded BaseUrl; a committed secret; a client-per-request; asserting on a cold
(no-warmup) run; adding the perf suite to `App.sln`; running Stress/Spike/Soak in the per-PR CI gate.

## Recipes

### A — add a scenario to an existing service project
1. Confirm the route is in `Constants/PerfEndpoints.cs` (add it if not) and the endpoint has an **SLO** in the
   central `appsettings.json` (add one — decide the target — if not).
2. Add a `[Fact]` + `TraitNames` category with a stable scenario name (§6).
3. Build the NBomber scenario via `PerformanceTestBase` using a **named load profile** (Smoke for the CI gate),
   a warmup, and the shared `HttpClient`.
4. `SloAssert` the returned `NodeStats` against the endpoint SLO. Nothing else asserts.

### B — scaffold a new service performance project
1. `cd tests/performance/Scenarios && dotnet new xunit -n App.<Service>.PerformanceTests -f net10.0`.
2. Replace the csproj: bare `PackageReference`s (NBomber, NBomber.Http, xunit, test sdk, FluentAssertions,
   coverlet), `IsTestProject=true`, references to `Infrastructure` + `Shared`, **no appsettings items**.
3. Add a `Services:<Service>` entry (if missing) + the endpoint's SLO to the central `appsettings.json`.
4. `Constants/PerfEndpoints.cs` + `TraitNames.cs`; one **Smoke** scenario proving the pipeline green.
5. Register the project in `App.Performance.sln`. Record the new scenarios + SLOs in `docs/tests.md` (Performance section).

---

## Pre-merge checklist
- [ ] Layout + one-way reference chain intact; perf suite is NOT in `App.sln`.
- [ ] No inline `Version=` (NU1008); FluentAssertions still 7.2.0; NBomber version confirmed to restore.
- [ ] No per-project appsettings; config changes went into the central file; no committed secret (`PERF_` env).
- [ ] Every scenario is an xUnit `[Fact]` with a `TraitNames` category, a stable name, a warmup, a **named
      load profile**, and an **`SloAssert`** against a config SLO (no inline rates/SLOs, no "didn't crash").
- [ ] Every asserted endpoint has a documented SLO in `docs/tests.md` (Performance section).
- [ ] `Shared`/`Infrastructure` changes matched by unit tests (or gap documented); the perf solution restores + builds.
- [ ] Heavy profiles (Stress/Spike/Soak) are NOT wired into the per-PR gate.

---

## §14 Running the performance tests
Needs the target **deployed + reachable** at the configured `BaseUrl` and a **quiet environment**. Like the
integration suite, **author + compile-verify** here; the user runs the actual load locally / in a dedicated
perf environment.
```bash
cd tests/performance
dotnet build App.Performance.sln -tl:off                       # build FIRST
# CI per-PR gate — Smoke only (short, deterministic):
dotnet test App.Performance.sln --no-build --filter "Category=Smoke" -tl:off
# On-demand heavier profiles against a dedicated perf env (never prod without sign-off):
dotnet test Scenarios/App.<Service>.PerformanceTests/... --no-build --filter "Category=Load" -tl:off
```
xUnit trait filter uses `Category=` (not `TestCategory=`). Point at an environment via
`appsettings.Local.json` or `PERF_SERVICES__<Service>__BASEURL` env var. **Note:** a green perf run needs
all services + Postgres up; CI compile-gates the suite and runs only the Smoke profile.

### Troubleshooting
| Symptom | Cause / fix |
|---|---|
| Restore fails **NU1008** | A `PackageReference` has an inline `Version=`. Remove it; pin centrally. |
| Restore fails on NBomber | Version pin not available — adjust the `<PackageVersion Include="NBomber" ...>` and record it. |
| p95 wildly high on first run | No warmup (§8) — add `WithWarmUpDuration`; don't assert cold. |
| Every request 401 | Auth token not minted/reused — check `PerformanceAuthHelper` + the `PERF_` env vars. |
| Sockets exhausted / skewed latency | Client-per-request — reuse the one `HttpClient` from the factory. |

---

## §15 Micro-benchmarks (separate track — BenchmarkDotNet)
For a hot **in-process** code path (serialization, pricing math, token issuance) where you need nanosecond-level,
allocation-aware measurement — **not** over-the-wire load — use **BenchmarkDotNet** in a dedicated
`*.Benchmarks` console project (Release-only, `[MemoryDiagnoser]`). It is out of scope for the NBomber
load suite; keep the two separate. Document any benchmark + its baseline in `docs/tests.md` (Performance section).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.