Fix instance MethodDataSource isolation#6379
Conversation
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| ErrorProne | 1 high |
| CodeStyle | 1 minor |
🟢 Metrics 5 complexity
Metric Results Complexity 5
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Code Review: Fix instance MethodDataSource isolation (#6379)OverviewFixes #6361 — a test class instance created solely to enumerate an instance-bound
Correctness
Verification performed
Design/architecture note (worth being explicit about, not a blocker)This trade-off intentionally gives up the "reuse enumeration instance as first test" perf optimization in exchange for correctness — every test generated from an instance-bound method data source now pays for one extra full instance construction + property injection (the enumeration-only instance), on top of its own. That's the right call: the previous optimization was observably broken (that's Minor nit (non-blocking)
Test coverageGood — the new tests cover the bug at the right levels (unit test for property caching, TestProject-level black-box isolation repro asserting instance identity across 3 generated tests, and an engine-level execution test asserting pass/fail counts). No gaps spotted for this fix's scope. Verdict✅ Looks good — correct fix for a real isolation bug, disposal path is sound, tests genuinely exercise the regression, and the code builds/passes as described in the PR's own validation steps. |
Summary
MethodDataSourceenumeration object as the first generated test instance.Validation
dotnet build TUnit.Engine\TUnit.Engine.csproj -c Releasedotnet build TUnit.TestProject\TUnit.TestProject.csproj -c Release(existing warning flood only)dotnet build TUnit.Engine.Tests\TUnit.Engine.Tests.csproj -c Release.\TUnit.TestProject\bin\Release\net10.0\TUnit.TestProject.exe --treenode-filter "/*/TUnit.TestProject.Bugs._6361/Issue6361InstanceMethodDataSourceIsolationTests/*" --disable-logo --no-progressdotnet test TUnit.Engine.Tests\TUnit.Engine.Tests.csproj -c Release --no-build --treenode-filter "/*/*/Issue6361Tests/*"(AOT case skipped locally)dotnet test TUnit.UnitTests\TUnit.UnitTests.csproj -c Release --no-build --treenode-filter "/*/*/PropertyInjectorTests/ResolveAndCacheProperties_CachesInjectedProperties"Fixes #6361