Test example code to ensure it runs
This PR introduces test files which run the code snippets in /examples and in README.md. As each scenario is unique and requires its own setup and assertions, each test is bespoke (rather than being auto-generated).
Motivation and Context
As part of #48 and the surrounding exploration of using simpler "definition" classes, I realized I'd have to ensure the example code still worked, so I thought I'd explore the idea of actually testing it.
It turns out this paid off, as a bunch of the examples were either broken themselves, or revealed bugs in the implementation.
How Has This Been Tested?
The PR consists almost entirely of tests. 😅
Breaking Changes
This should not include any breaking changes.
Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [x] Documentation update
Checklist
- [x] I have read the MCP Documentation
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [x] I have added appropriate error handling
- [x] I have added or updated documentation as needed
⚠️ Before Merging
- [ ] Rebase & squash into fewer commits
Additional context
I have added <!-- SNIPPET ID: snippet_name --> comments to the snippets we need to be able to extract from README.md. These will be invisible to readers, but make it much simpler to find the snippets than needing to hard code their contents or some other such shenanigans.
I think the concept is solid. In this case, having the commits split makes it harder to follow later, so can you squash them into a single commit?
@koic I had kept the commits granular so it was clear which changes were required by which tests, in particular so reviewers can discuss them separately. I'm happy to squash after addressing review feedback though 👍
@koic I've squashed the commits and addressed your feedback 👍
The only thing remaining is addressing the test I had to skip. I'm not sure what we want to do there, or if it's worth fixing, since there are multiple PRs open that might affect it (#54, #56).
I've rebased again, just to keep this in sync with main. #33 added some more examples, so we'll have to add the tests for those too, but I think it would make sense to merge this sooner than later, and open a followup PR to add the missing tests.