Files
mic-check/tests/api/MicCheck.Api.Tests.Integration/readme.md
James Wampler 4621e8380b Add MicCheck.Api.Tests.Integration project
NUnit integration tests that target a running API by URL and seed/clean
data directly in Postgres. Settings (BaseUrl, DbConnectionString) come
from .runsettings or environment variables so tests can be pointed at
any environment. HTTP requests live in HttpFiles/*.http; assertion
failures include a fresh DB snapshot of the relevant rows. First test
covers the flag-enabled path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-03 19:12:47 -07:00

39 lines
1.3 KiB
Markdown

# MicCheck.Api.Tests.Integration
Black-box integration tests. Targets a running MicCheck.Api instance by URL and seeds/cleans data directly in the Postgres database.
## Running against an environment
Two settings are required: `BaseUrl` and `DbConnectionString`.
### Via .runsettings (recommended for local + CI)
```
dotnet test --settings local.runsettings
```
Copy `local.runsettings` to e.g. `staging.runsettings` and override the values for other environments.
### Via command-line
```
dotnet test -- TestRunParameters.Parameter\(name=\"BaseUrl\",value=\"https://staging.example.com\"\) ^
TestRunParameters.Parameter\(name=\"DbConnectionString\",value=\"Host=...\"\)
```
### Via environment variables (overrides .runsettings)
```
MICCHECK_API_BASE_URL=...
MICCHECK_DB_CONNECTION_STRING=...
MICCHECK_ACCEPT_ANY_SERVER_CERTIFICATE=true|false
```
## Patterns
- Tests seed their own data **directly in the database**, never through the API.
- Per-test data is seeded in `[SetUp]`. Reusable cross-test data goes in `[OneTimeSetUp]`.
- Cleanup runs in `[TearDown]` / `[OneTimeTearDown]`, also directly in the database.
- HTTP requests are defined in `HttpFiles/*.http` and executed via `FlagApiHttpClient`.
- Assertion failure messages include a fresh snapshot of the relevant rows in the database.