-
-
Notifications
You must be signed in to change notification settings - Fork 96
Fix "Test instance is null" error for empty InstanceMethodDataSource #2863
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
Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
|
Claude finished @Copilot's task —— View job Code Review Complete ✅Reviewing PR #2863: Fix "Test instance is null" error for empty InstanceMethodDataSource Todo List
Review SummaryThis PR provides a solid fix for issue #2862. The implementation is clean, well-tested, and addresses the root cause effectively. ✅ Code Quality & Best PracticesExcellent:
Minor suggestions:
✅ Bug AnalysisNo bugs identified. The fix correctly:
✅ Performance ConsiderationsGood performance characteristics:
✅ SecurityNo security concerns identified:
✅ Test CoverageComprehensive test coverage: Unit Tests (
Integration Test (
🎯 Root Cause AnalysisThe fix correctly addresses the core issue: Before: Empty data sources yielded zero results → test framework couldn't create instances → "Test instance is null" error After: Empty data sources yield one empty result ✅ RecommendationAPPROVE - This is a well-implemented fix that:
The solution is production-ready and should resolve issue #2862 effectively. |
|
Claude finished @Copilot's task —— View job Reviewing PR #2863: Fix "Test instance is null" error for empty InstanceMethodDataSource Todo List
Review SummaryThis PR provides a solid fix for issue #2862. The implementation is clean, well-tested, and addresses the root cause effectively. ✅ Code Quality & Best PracticesExcellent:
Minor suggestions:
✅ Bug AnalysisNo bugs identified. The fix correctly:
✅ Performance ConsiderationsGood performance characteristics:
✅ SecurityNo security concerns identified:
✅ Test CoverageComprehensive test coverage: Unit Tests (
Integration Test (
🎯 Root Cause AnalysisThe fix correctly addresses the core issue: Before: Empty data sources yielded zero results → test framework couldn't create instances → "Test instance is null" error After: Empty data sources yield one empty result ✅ RecommendationAPPROVE - This is a well-implemented fix that:
The solution is production-ready and should resolve issue #2862 effectively. |
|
@claude [Claude Auto-Fix] Detected failed modularpipeline build (check run 48046990674). Please analyze the build failure at https://github.com/thomhurst/TUnit/actions/runs/16952146778/job/48046990674 and commit a fix for it. Instructions:
Focus on fixing only the build errors - do not make unrelated changes. |
|
@claude [Claude Auto-Fix] Detected failed modularpipeline build (check run 48046990674). Please analyze the build failure at https://github.com/thomhurst/TUnit/actions/runs/16952146778/job/48046990674 and commit a fix for it. Instructions:
Focus on fixing only the build errors - do not make unrelated changes. |
|
Claude finished @thomhurst's task —— View job Build Fix Complete ✅Todo List
Fix SummaryProblem: The Root Cause:
Solution Applied: Tests Now Verify:
Commit: The build should now pass. The new tests will validate that the original PR fix for issue #2862 works correctly end-to-end. |
Replace complex manual DataGeneratorMetadata construction with simple declarative TUnit tests. The original approach had multiple compilation errors due to incorrect metadata object construction. The new approach follows TUnit patterns and tests the fix for issue #2862 end-to-end by verifying empty data sources work without 'Test instance is null' errors. Co-authored-by: Tom Longhurst <thomhurst@users.noreply.github.com>

Fixes an issue where tests using
InstanceMethodDataSourcethat return empty collections would fail with "Test instance is null for test after instance creation".Problem
When an
InstanceMethodDataSourcereturns an empty collection, the test framework would fail to create test instances properly. For example:Root Cause
The issue was in
MethodDataSourceAttribute.GetDataRowsAsync():InstanceMethodDataSourcereturned an emptyIEnumerable, the foreach loop never executed, yielding zero data rowsNoDataSourcealways yields exactly one empty result:[]Solution
Modified
MethodDataSourceAttribute.GetDataRowsAsync()to ensure empty data sources behave consistently withNoDataSource:IAsyncEnumerable- now yields one empty result instead of zeroTask<IEnumerable>- now yields one empty result instead of zeroIEnumerable- now yields one empty result instead of zeroThis ensures all empty data sources yield exactly one result with an empty array
[], making them consistent withNoDataSourceand preventing the "test instance is null" error.Validation
Fixes #2862.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.