-
-
Notifications
You must be signed in to change notification settings - Fork 96
Fix data and properties being injected/initialised too eagerly #2818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…hey don't need to be
…reation - Changed test instance creation to use lazy initialization with PlaceholderInstance - Test instances are now created only when tests actually execute, not during discovery - This prevents expensive resources (Redis, SQL, MessageBus) from being initialized for filtered-out tests - Added PlaceholderInstance as a marker for tests awaiting lazy initialization - Fixed issue where dynamic tests had null instances instead of PlaceholderInstance - Updated SingleTestExecutor to handle PlaceholderInstance and create real instances on demand - Modified TestBuilder to use factory functions for deferred instance creation This fixes the critical bug where injected properties, constructor args, and method args were being eagerly initialized during test discovery, causing unnecessary resource consumption even for tests that wouldn't run due to filters.
|
Claude finished @thomhurst's task —— View job Code Review Complete ✅I've reviewed this pull request focusing on code quality, potential bugs, performance, security concerns, and test coverage. Review Tasks:
Analysis Summary:This PR addresses issue #2647 by preventing eager initialization of test class instances and data properties during test discovery. The main changes introduce a 🟢 Positive AspectsWell-designed Lazy Loading Pattern
Consistent Implementation
Performance Improvement
🟡 Areas for Improvement1. Missing XML Documentation
// Good: Has summary documentation explaining purpose
// Consider: Adding <example> tags to clarify usage vs SkippedTestInstance2. Error Handling Considerations
3. Code Consistency
TestClassInstanceFactory = () => Task.FromResult<object>(null!)This pattern appears multiple times. Consider extracting to a static readonly field: private static readonly Func<Task<object>> NullInstanceFactory = () => Task.FromResult<object>(null!);🟢 Security Assessment: No Concerns
🟡 Test Coverage ConsiderationsMissing Test CoverageThe PR doesn't include test changes, which raises some concerns:
RecommendationConsider adding integration tests that:
🟢 Performance Impact: Positive
🔧 Minor Suggestions1. Consider Factory Method Naming
public Func<Task<object>>? LazyTestClassInstanceFactory { get; init; }2. Null Safety
instanceFactory = async () => {
ArgumentNullException.ThrowIfNull(capturedMetadata);
return await CreateInstance(capturedMetadata, capturedClassGenericArgs, capturedClassData, capturedContext);
};Overall Assessment: ✅ Approved with Minor SuggestionsThis is a well-implemented performance optimization that effectively solves the eager initialization problem. The architecture is sound, the code is clean, and the changes are consistent throughout the codebase. The main recommendation is to add test coverage to ensure the lazy loading behavior is properly validated and to prevent regressions. Code Quality: 8.5/10 |
|
Claude finished @thomhurst's task —— View job Code Review Complete ✅I've reviewed this pull request focusing on code quality, potential bugs, performance, security concerns, and test coverage. Review Tasks:
Analysis Summary:This PR addresses issue #2647 by preventing eager initialization of test class instances and data properties during test discovery. The main changes introduce a 🟢 Positive AspectsWell-designed Lazy Loading Pattern
Consistent Implementation
Performance Improvement
🟡 Areas for Improvement1. Missing XML Documentation
// Good: Has summary documentation explaining purpose
// Consider: Adding <example> tags to clarify usage vs SkippedTestInstance2. Error Handling Considerations
3. Code Consistency
TestClassInstanceFactory = () => Task.FromResult<object>(null!)This pattern appears multiple times. Consider extracting to a static readonly field: private static readonly Func<Task<object>> NullInstanceFactory = () => Task.FromResult<object>(null!);🟢 Security Assessment: No Concerns
🟡 Test Coverage ConsiderationsMissing Test CoverageThe PR doesn't include test changes, which raises some concerns:
RecommendationConsider adding integration tests that:
🟢 Performance Impact: Positive
🔧 Minor Suggestions1. Consider Factory Method Naming
public Func<Task<object>>? LazyTestClassInstanceFactory { get; init; }2. Null Safety
instanceFactory = async () => {
ArgumentNullException.ThrowIfNull(capturedMetadata);
return await CreateInstance(capturedMetadata, capturedClassGenericArgs, capturedClassData, capturedContext);
};Overall Assessment: ✅ Approved with Minor SuggestionsThis is a well-implemented performance optimization that effectively solves the eager initialization problem. The architecture is sound, the code is clean, and the changes are consistent throughout the codebase. The main recommendation is to add test coverage to ensure the lazy loading behavior is properly validated and to prevent regressions. Code Quality: 8.5/10 |
Fixes #2647