Repository navigation
docs: add the rule and the skill for test scenarios - #70
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The refactor preserves existing seeding behavior, and no blocking issues remain.
No open issues 🎉
What changed in this PR
Documents the reusable emulator test scenario pattern requested in #67 and updates existing tests to follow it, without changing the library.
Changes:
- Adds scenario rules and a test-data-seeding skill.
- Extracts both scenarios into dedicated files with struct
TestDatarecords. - Updates tests to read seeded values through record patterns.
| File | Description |
|---|---|
| tests/Cosmos.Tests/Scenarios/SingleItemScenario.fs | Extracts the single-item scenario. |
| tests/Cosmos.Tests/Scenarios/MultipleItemsScenario.fs | Extracts the two-item scenario. |
| tests/Cosmos.Tests/ReadOperationTests.fs | Uses the single-item data record. |
| tests/Cosmos.Tests/ReadManyOperationTests.fs | Replaces list matching with record matching. |
| tests/Cosmos.Tests/IterationExtensionsTests.fs | Uses the shared two-item data record. |
| tests/Cosmos.Tests/FSharp.Azure.Cosmos.Tests.fsproj | Compiles scenarios before their consumers. |
| .github/skills/test-data-seeding/SKILL.md | Provides scenario guidance and examples. |
| .github/instructions/test-scenarios.instructions.md | Defines test scenario rules. |
| .claude/rules/test-scenarios.md | Shares the rules with Claude Code. |
Review effort: Balanced
xperiandri
force-pushed
the
docs/test-scenarios
branch
from
October 18, 2026 01:05
66df4ca to
bb90e0e
Compare
xperiandri
commented
Oct 18, 2026
SingleItemScenario and MultipleItemsScenario were in the files of their tests and gave their items through members. MultipleItemsScenario gave an F# list. Thus each test had to match the list and fail on a wrong length. Move each scenario into tests/Cosmos.Tests/Scenarios, in a namespace of its own. Each scenario creates its data in the constructor of its TestApplicationFactory and writes the data in SeedDataAsync. It gives the values that the tests read through a [<Struct>] TestData record, and the tests read the values with a record pattern. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xperiandri
force-pushed
the
docs/test-scenarios
branch
from
October 18, 2026 01:15
bb90e0e to
748e2c4
Compare
An emulator test class that writes the same data in each test repeats the setup in each test and hides what the test examines. The instructions did not tell how tests get seeded data. Add .github/instructions/test-scenarios.instructions.md, which Claude Code reads through .claude/rules/test-scenarios.md. It has only the rules that apply to each test file: when a scenario is necessary, when a test writes its own data, and how a test refers to a scenario. The rules load with each test file, so the file stays short. Add the skill test-data-seeding in .github/skills. It has the procedure: how to write a scenario, its TestData record and the test class, with examples that compile. A skill loads only when an agent writes or changes a scenario. Claude Code finds the skill through the .claude/skills junction that Directory.Build.targets creates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xperiandri
force-pushed
the
docs/test-scenarios
branch
from
October 18, 2026 13:31
748e2c4 to
914a824
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
A scenario is a class that writes the data of a test class into the database of each test before the test starts. The tests read this data. They do not write it. This pull request writes down how to make a scenario. It also makes the two scenarios of the repository obey the new rule. The review of #67 asked for this rule: "If you always seed the same data why don't you derive from
OperationTestBase<>with scenario?"SingleItemScenarioandMultipleItemsScenarioare now in files of their own intests/Cosmos.Tests/Scenarios/, each in a namespace of its own. Each scenario creates its data in the constructor ofTestApplicationFactoryand writes the data inSeedDataAsync. The tests read the values from a[<Struct>]recordTestDatawith a record pattern. They refer to theTestApplicationFactoryof a scenario through the namespace of the scenario, for exampleOperationTestBase<SingleItemScenario.TestApplicationFactory>. Thus the test class shows which scenario it uses. They open the namespace for the other types of the scenario. Before this change,MultipleItemsScenariogave an F# list. Thus each test had to match the list and fail on a wrong length..github/instructions/test-scenarios.instructions.mdhas only the rules that apply to each test file: when a scenario is necessary, when a test writes its own data, and how a test refers to a scenario. Copilot uses it fortests/**/*.fs, and Claude Code reads it through.claude/rules/test-scenarios.md. The procedure is not repeated there: an instructions file loads with each test file, a skill loads only when an agent writes a scenario..github/skills/test-data-seeding/SKILL.mdtells how to write a scenario and its test class. It comes from the skill with the same name in the application of the maintainer. It is changed for the test infrastructure of this repository:DatabaseTestApplicationFactory,OperationTestBase<_>andCosmosAssert. Its two examples compile, and the example test passes on the emulator. Copilot finds the skill in.github/skills(skill locations). Claude Code finds it through the.claude/skillsjunction thatDirectory.Build.targetscreates. This is the first skill of the repository, so the junction did not exist before.Types of changes
What types of changes does your code introduce to FSharp.Azure.Cosmos?
Put an
xin the boxes that applyThe change has no effect on the library. It changes only tests and instructions.
Checklist
Further comments
#67 builds on this pull request. Its scenario
DurationsScenariohas the same form.🤖 Generated with Claude Code