Repository navigation
test: add SDK-level tests resolving MediatR handlers from a request against a real headless solution and PSI - #122
Merged
Merged
Conversation
Exercise the plugin against a real headless solution: the ReSharper test framework restores MediatR, builds the PSI caches, and LibraryAdaptor resolves handlers the same way it does in the IDE. Covers a handler declared in a separate file, a command without a response, a notification with two handlers, a request with no handler, and a type that is not a request at all. Add Microsoft.NET.Test.Sdk so dotnet test discovers the project; without it VSTest found no tests and exited 0. Expose plugin internals to the test assembly so LibraryAdaptor is reachable. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
The ReSharper test framework targets net472, so the tests cannot execute on the ubuntu runner the build job uses. Add a separate windows-latest job that runs the test project directly. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
VSTest has no built-in 'GitHubActions' logger, so the test run failed before executing a single test. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
The adapter the ReSharper SDK drops in the output directory cannot be loaded by VSTest, so discovery found nothing and the job passed without executing a single test. Reference NUnit3TestAdapter directly, and add a trx-based guard so an empty run can never report green again. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
The SDK's copy in the output directory shadows it and fails to load, so discovery found no tests. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
The adapter lives in the NuGet cache, which dotnet test only populates once it runs, so the existence check fired too early. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
The attribute pulls in a JetBrains-hosted data package that is no longer resolvable, failing fixture setup. The lookup data does not need it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
kzryzstof
marked this pull request as draft
September 5, 2026 16:33
The attribute was not the cause: fixture setup fails identically without it, and the pre-existing suite fails the same way. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TFseivAgekzsg6Sv2Negry
- Mark all test handler classes as `internal` for stricter visibility. - Add `[TestNetCoreLatest]` to `MediatorHandlerLookupTests` to replace the default framework, ensuring compatibility with test dependencies. - Include a new `AGENTS.md` file summarizing the project structure, conventions, and build/test guidelines.
- Introduced `LookupTestBase`, a reusable base class for testing handler resolution across various scenarios. - Added MediatR and Mediator-specific test classes to validate handler lookups for requests and notifications. - Implemented validation for cases with multiple handlers, no handlers, nested handlers, and custom request types. - Included test solution files and directories to simulate realistic conditions.
- Updated `[TestPackages]` attribute in `MediatRRequestsTests` to include MediatR versions `13.1.0` and `14.2.0`.
… load - Added `TestSolutionFiles` to dynamically enumerate all .cs files in the test solution for MediatR and Mediator libraries. - Updated tests to use `TestSolutionFiles` for cleaner, reusable file references. - Improved `FindDeclarationIdentifier` to handle both fully qualified and short type names with enhanced validation. - Refined test scenarios to streamline handler and request resolution logic.
- Updated `[MediatRTestPackages]` attribute to exclude older MediatR versions (V12, V13). - Fixed class name typo from `MediatrCreateHandlrContextActionTests` to `MediatRCreateHandlrContextActionTests` for consistency.
- Replaced `[MediatRTestPackages]` with version-specific attributes (`[MediatRV12TestPackages]`, `[MediatRV13TestPackages]`, `[MediatRV14TestPackages]`). - Refactored test base classes (`MediatRNotificationsTestsBase`, `MediatRRequestsTestsBase`, and `MediatRCreateHandlrContextActionTestsBase`) for improved reusability. - Added version-specific test classes for Notifications, Requests, and CreateHandlrContextAction to separately validate behavior for MediatR versions V12, V13, and V14
- Replaced `[MediatorTestPackages]` with `[MediatorV3TestPackages]` for precision. - Refactored test base classes (`MediatorNotificationsTestsBase`, `MediatorRequestsTestsBase`) to abstract shared logic. - Added version-specific test classes (`MediatorNotificationsTestsV3`, `MediatorRequestsTestsV3`) to handle Mediator V3 testing separately.
- Deleted obsolete test data files from `MediatorHandlerLookupTests` (`NotARequest.cs`, `OrphanQuery.cs`, `SomeCommand.cs`, `SomeQuery.cs`, `SomeQueryHandler.cs`, `SomethingHappened.cs`). - Simplified the test suite by cleaning up unused or irrelevant test artifacts.
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.
Summary
The plugin's handler resolution ran only against a live IDE — the existing suite covered the
"create handler" context action via gold files, but nothing exercised the lookup that answers
"given this request, where is its handler?". This adds component tests for that path, driving
the real ReSharper test framework so the resolution runs against restored MediatR assemblies
and genuine PSI caches rather than mocks.
Changes
MediatorHandlerLookupTests, deriving fromBaseTestWithSingleProject, which commitsdocuments, takes a read lock, locates a type declaration's name token, and asserts the
handlers
LibraryAdaptor.FindHandlersresolves for it.IRequestcommand with noresponse, a notification with two handlers, a request with no handler, and a type that is
not a request.
test/data/MediatorHandlerLookupTests/. These assert thelookup result directly, so no
{caret}markers or.goldfiles are involved.Microsoft.NET.Test.Sdkto the test project. Without itdotnet testdiscovered notests and exited 0, so the existing suite never ran.
InternalsVisibleToon the plugin assembly so the internalLibraryAdaptorisreachable from tests.
Octelys.MediatorPlugin.Testsnamespace and assembly name.Reviewer note: these tests are unrun. The project targets
net472and the ReSharper testframework needs Mono or Windows, so
dotnet testcannot execute them on macOS or on thecurrent
ubuntu-latestCI job — discovery reaches VSTest and stops at a missing Mono host.They need a Windows run to confirm they pass. CI is not wired up in this PR.
Related
Generated by describe-pr skill v1.1.0