From 6a1ab257bed5bdfb17718cb64b7cf3c2f60a07d5 Mon Sep 17 00:00:00 2001 From: XperiAndri Date: Sat, 10 Oct 2026 15:30:03 +0200 Subject: [PATCH] test: sort the test category attributes by name The attributes of tests/Cosmos.Tests/TestCategories.fs were in the order of the string constants they once replaced, with later ones appended. They are sorted by type name now, as the review of #44 asks. A path-scoped instruction keeps them sorted: .github/instructions/test-categories.instructions.md applies to every file named TestCategories.fs for GitHub Copilot, and .claude/rules/test-categories.md imports it for Claude Code with the same path pattern. Co-Authored-By: Claude Opus 5.5 --- .claude/rules/test-categories.md | 6 ++ .../test-categories.instructions.md | 7 ++ tests/Cosmos.Tests/TestCategories.fs | 74 +++++++++---------- 3 files changed, 50 insertions(+), 37 deletions(-) create mode 100644 .claude/rules/test-categories.md create mode 100644 .github/instructions/test-categories.instructions.md diff --git a/.claude/rules/test-categories.md b/.claude/rules/test-categories.md new file mode 100644 index 00000000..44b98c99 --- /dev/null +++ b/.claude/rules/test-categories.md @@ -0,0 +1,6 @@ +--- +paths: + - "**/TestCategories.fs" +--- + +@../../.github/instructions/test-categories.instructions.md diff --git a/.github/instructions/test-categories.instructions.md b/.github/instructions/test-categories.instructions.md new file mode 100644 index 00000000..8516ae64 --- /dev/null +++ b/.github/instructions/test-categories.instructions.md @@ -0,0 +1,7 @@ +--- +applyTo: "**/TestCategories.fs" +--- + +# Test category attributes + +Keep the `TestCategoryBaseAttribute` descendants of this file sorted by type name. Add a new attribute at its place in that order, never at the end of the file. diff --git a/tests/Cosmos.Tests/TestCategories.fs b/tests/Cosmos.Tests/TestCategories.fs index aedffa65..238cceb4 100644 --- a/tests/Cosmos.Tests/TestCategories.fs +++ b/tests/Cosmos.Tests/TestCategories.fs @@ -1,7 +1,7 @@ // Every TestCategoryBaseAttribute descendant used to categorize tests in this project, one per operation or -// component, in the same order as the string constants they replace used to be declared in. An abstract -// MSTest attribute whose TestCategories list is picked up by --filter TestCategory=... exactly like -// []'s, but self-sufficient: no separate string constant needed to know what to pass it. +// component, sorted by name. An abstract MSTest attribute whose TestCategories list is picked up by +// --filter TestCategory=... exactly like []'s, but self-sufficient: no separate string constant needed +// to know what to pass it. // The categories every test project shares, such as the Cosmos DB Emulator one, live in the test infrastructure project. namespace FSharp.Azure.Cosmos.Tests @@ -16,33 +16,17 @@ type CreateTestCategoryAttribute () = inherit TestCategoryBaseAttribute () override _.TestCategories = [| "Create" |] :> IList -type ReadTestCategoryAttribute () = - inherit TestCategoryBaseAttribute () - override _.TestCategories = [| "Read" |] :> IList - -type ReadManyTestCategoryAttribute () = - inherit TestCategoryBaseAttribute () - override _.TestCategories = [| "ReadMany" |] :> IList - -type UpsertTestCategoryAttribute () = - inherit TestCategoryBaseAttribute () - override _.TestCategories = [| "Upsert" |] :> IList - -type ReplaceTestCategoryAttribute () = - inherit TestCategoryBaseAttribute () - override _.TestCategories = [| "Replace" |] :> IList - -type PatchTestCategoryAttribute () = - inherit TestCategoryBaseAttribute () - override _.TestCategories = [| "Patch" |] :> IList - type DeleteTestCategoryAttribute () = inherit TestCategoryBaseAttribute () override _.TestCategories = [| "Delete" |] :> IList -type ReadExtensionsTestCategoryAttribute () = +/// +/// Categorizes as both a fast, emulator-free unit test and the probe that gates the +/// use of IcedTasks computation expressions in library code. +/// +type IcedTasksProbeTestCategoryAttribute () = inherit TestCategoryBaseAttribute () - override _.TestCategories = [| "ReadExtensions" |] :> IList + override _.TestCategories = [| "Unit"; "IcedTasksProbe" |] :> IList /// /// Categorizes an emulator-backed integration test as covering the iteration extensions: @@ -52,18 +36,6 @@ type IterationExtensionsTestCategoryAttribute () = inherit TestCategoryBaseAttribute () override _.TestCategories = [| "IterationExtensions" |] :> IList -type ValidationTestCategoryAttribute () = - inherit TestCategoryBaseAttribute () - override _.TestCategories = [| "Validation" |] :> IList - -/// -/// Categorizes as both a fast, emulator-free unit test and the probe that gates the -/// use of IcedTasks computation expressions in library code. -/// -type IcedTasksProbeTestCategoryAttribute () = - inherit TestCategoryBaseAttribute () - override _.TestCategories = [| "Unit"; "IcedTasksProbe" |] :> IList - /// /// Categorizes as both a fast, emulator-free unit test and coverage for the /// iteration extensions: and @@ -73,6 +45,26 @@ type IterationExtensionsUnitTestCategoryAttribute () = inherit TestCategoryBaseAttribute () override _.TestCategories = [| "Unit"; "IterationExtensions" |] :> IList +type PatchTestCategoryAttribute () = + inherit TestCategoryBaseAttribute () + override _.TestCategories = [| "Patch" |] :> IList + +type ReadExtensionsTestCategoryAttribute () = + inherit TestCategoryBaseAttribute () + override _.TestCategories = [| "ReadExtensions" |] :> IList + +type ReadManyTestCategoryAttribute () = + inherit TestCategoryBaseAttribute () + override _.TestCategories = [| "ReadMany" |] :> IList + +type ReadTestCategoryAttribute () = + inherit TestCategoryBaseAttribute () + override _.TestCategories = [| "Read" |] :> IList + +type ReplaceTestCategoryAttribute () = + inherit TestCategoryBaseAttribute () + override _.TestCategories = [| "Replace" |] :> IList + /// /// Categorizes as both a fast, emulator-free unit test and coverage for the /// module. @@ -89,6 +81,14 @@ type TestInfrastructureUnitTestCategoryAttribute () = inherit TestCategoryBaseAttribute () override _.TestCategories = [| "Unit"; "TestInfrastructure" |] :> IList +type UpsertTestCategoryAttribute () = + inherit TestCategoryBaseAttribute () + override _.TestCategories = [| "Upsert" |] :> IList + +type ValidationTestCategoryAttribute () = + inherit TestCategoryBaseAttribute () + override _.TestCategories = [| "Validation" |] :> IList + /// /// Categorizes as both a fast, emulator-free unit test and coverage for the /// collection functions of , which every project compiles.