You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/instructions/tests.instructions.md
+44-26Lines changed: 44 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
description: "Use when writing, editing, or reviewing Pester test files under the tests/ folder. Covers shared repository setup, auth case iteration, naming conventions, and skip patterns for the GitHub module integration tests."
2
+
description: "Use when writing, editing, or reviewing Pester test files under the tests/ folder. Covers per-test-file repository setup, self-contained test lifecycle, auth case iteration, naming conventions, and skip patterns for the GitHub module integration tests."
3
3
applyTo: "tests/**"
4
4
---
5
5
# Integration Test Conventions
@@ -54,22 +54,26 @@ Cases 4 (`repository`) and 7 (`enterprise`) skip repo creation. Cases 1 and 3 sh
54
54
55
55
## Setup and teardown
56
56
57
-
Shared test infrastructure is provisioned once per workflow run using `BeforeAll.ps1` and torn down using `AfterAll.ps1`.
57
+
Test infrastructure is provisioned once per workflow run using `BeforeAll.ps1` and torn down using `AfterAll.ps1`.
58
58
For generic guidance on setup/teardown scripts, see the
-`$id` must always be `$env:GITHUB_RUN_ID` — never `[guid]::NewGuid()` or `Get-Random`.
194
208
- Skip repo-dependent tests with `-Skip:($OwnerType -in ('repository', 'enterprise'))`.
195
209
- Disconnect all sessions in `AfterAll`: `Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent`.
196
-
- Test-specific ephemeral resources (releases, secrets, variables, environments, teams) are created and
197
-
cleaned up within each test file. Only repositories are shared.
198
-
-`Repositories.Tests.ps1` is the exception — it creates and deletes its own repos because it tests CRUD.
210
+
- Each test file uses its own repository: `{TestName}-{OS}-{TokenType}-{RunID}`. No two test files share a repository.
211
+
- Each test file is self-contained and responsible for its own setup and teardown:
212
+
-**BeforeAll (per-context):** Ensure the repository exists via `Set-GitHubRepository`. Clean up stale test-specific resources from prior runs (re-runs with the same `GITHUB_RUN_ID`).
213
+
-**AfterAll (per-context):** Remove all test-specific resources created during the run (environments, releases, secrets, variables, etc.).
214
+
- Any individual test file or auth context can be re-run independently. Tests must not assume clean initial state — they must be idempotent.
215
+
- Tests run in parallel across OSes (Linux, macOS, Windows) and in sequence across auth contexts (7 cases). Resource names must include enough dimensions to prevent collisions across all parallel and sequential axes.
216
+
-`Repositories.Tests.ps1` is independent — it creates and deletes its own repos because it tests CRUD.
0 commit comments