Add ExperimentFramework.Testing package for deterministic testing#55
Conversation
Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #55 +/- ##
=======================================
Coverage ? 83.23%
=======================================
Files ? 184
Lines ? 6860
Branches ? 1164
=======================================
Hits ? 5710
Misses ? 1150
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds a new ExperimentFramework.Testing package that provides testing utilities for deterministic experiment testing without requiring heavy mocking. The package introduces forced selection, trace capture, test harnesses, and framework-agnostic assertions.
Changes:
- Core testing infrastructure with
TestSelectionProvider,ExperimentTestScope, andExperimentTestHostfor deterministic test routing - Observability components including
InMemoryExperimentEventSink,TraceCapturingDecorator, andExperimentTraceAssertionsfor capturing and asserting on experiment behavior - Cross-strategy testing support via
ExperimentTestMatrix.RunInAllProxyModes()
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 19 comments.
Show a summary per file
| File | Description |
|---|---|
| TestInterfaces.cs | Test interface definitions for IMyDatabase with control and condition implementations |
| InMemoryExperimentEventSinkTests.cs | Unit tests for event sink's record, clear, and count functionality |
| ExperimentTraceAssertionsTests.cs | Tests for trace assertion methods (ExpectRouted, ExpectFallback, ExpectCall, GetEventsFor) |
| ExperimentTestHostTests.cs | Integration tests validating forced selection, frozen selection, and scope restoration |
| ExperimentFramework.Testing.Tests.csproj | Test project configuration targeting .NET 10.0 with xUnit dependencies |
| TraceCapturingDecoratorFactory.cs | Factory for creating trace capturing decorators from event sink |
| TraceCapturingDecorator.cs | Decorator that captures experiment execution traces with timing and exception handling |
| TestSelectionProviderFactory.cs | Factory for creating test selection providers |
| TestSelectionProvider.cs | Custom selection provider supporting forced control/condition selection and frozen selections |
| TestSelectionContext.cs | Ambient context using AsyncLocal for scoped test selection overrides |
| ServiceExperimentBuilderExtensions.cs | Extension method .UsingTest() for seamless test selection mode integration |
| README.md | Comprehensive documentation with examples, API reference, and usage patterns |
| InMemoryExperimentEventSink.cs | Thread-safe in-memory event storage using ConcurrentBag |
| ExperimentTraceEvent.cs | Event model capturing service type, method, trial key, timing, and exceptions |
| ExperimentTraceAssertions.cs | Framework-agnostic assertion helpers for trace validation |
| ExperimentTestScope.cs | Scoped context for forcing trial selection with IDisposable pattern |
| ExperimentTestMatrix.cs | Utility for running tests across multiple proxy strategies |
| ExperimentTestHost.cs | Fluent builder for creating test hosts with DI and experiment configuration |
| ExperimentFramework.Testing.csproj | Package project targeting net8.0/9.0/10.0 with proper dependencies and metadata |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/ExperimentFramework.Testing/ExperimentFramework.Testing.csproj
Outdated
Show resolved
Hide resolved
tests/ExperimentFramework.Testing.Tests/ExperimentTraceAssertionsTests.cs
Show resolved
Hide resolved
tests/ExperimentFramework.Testing.Tests/ExperimentTestHostTests.cs
Outdated
Show resolved
Hide resolved
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
|
@copilot Retry. |
… fix logic issues Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
I've successfully addressed all the PR review feedback. Changes made in commit 327c3aa: Fixed Issues:
New Tests Added:
Total: 27/27 tests passing ✓ |
Code Coverage |
Implementation Plan for ExperimentFramework.Testing Package
Original prompt
ExperimentFramework.Testingpackage for deterministic routing, harnesses, and assertions #54💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.