Skip to content

spike: Metalama.Testing.AspectTesting beside xunit.v3 on MTP - #105

Merged
CaffeinatedCoder merged 1 commit into
release/2.3.0from
test/aspect-testing-spike
Oct 28, 2026
Merged

CaffeinatedCoder merged 1 commit into
release/2.3.0from
test/aspect-testing-spike

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #93

Problem

Gaël Fraiteur of Metalama suggested Metalama.Testing.AspectTesting (discussion 2305): its tests compare the transformed code with a stored file, so a reviewer can check the output instead of the generator. The package runs on xunit v2, and this repository on xunit.v3 under Microsoft Testing Platform.

Change

  • spikes/AspectTestingSpike: an xunit v2 / VSTest project with its own global.json and Directory.Build.props, referencing the real src/CodoMetis.TypeKit.Generators. It has four cases: OrderId, Email, OrderStatus, and a refusal (CMTK1002). The README holds the question, the answer and 16 measured findings.

The answer:

  • It works, against the real aspects and fabric. A defect seeded in a scratch copy of src/ failed the two cases it touches, with 7 changed lines.
  • It runs only as a separate command. One VSTest project in the solution makes dotnet test --solution refuse the whole run. The workaround, IsTestProject=false, runs nothing and exits 0.
  • The expected files are hard to review whole. They run to 235–349 fully qualified lines per type.

Decision: not adopted. The way the generators are tested does not change, so no decision record. The spike stays as the record. Reading its output found dead code in every generated TryParse (#100).

Tests

  • In the spike folder, dotnet test AspectTests/AspectTests.csproj (VSTest, through the folder's global.json): 4 passed.
  • Conventions: 1,510 passed. Spikes are not in the solution and are never packed.

🤖 Generated with Claude Code

Metalama.Testing.AspectTesting 2026.1.30 tests the real generators,
internal aspects and TransitiveProjectFabric included, through a project
reference. It runs on xunit v2 and VSTest, so it stays out of the
solution's test run.

- It runs as a project of its own with its own global.json, which keeps
  the SDK pin and drops the test key. `dotnet test` from the spike folder
  passes 4 of 4. From the root, the MTP selection refuses it.
- In a scratch .slnx, one VSTest project makes `dotnet test --solution`
  refuse the whole run, so no other test runs. IsTestProject=false hides
  it from that run, but then VSTest's `dotnet test` also runs nothing and
  exits 0.
- `dotnet vstest` on the built dll runs it from anywhere. CI would need
  one more step, which was not run.
- A seeded defect in a scratch copy of src/ fails the two snapshots
  whose output it changes.
- Plain, validated and closed-set shapes give 235 to 349 lines each.
  They are formatted but fully qualified, so they suit a review per
  member, not per file.
- Reading them showed dead code after the return in every generated
  TryParse(string?): TryParseTemplate's meta.InsertStatement calls are
  still emitted after a compile-time return.

Refs #93

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 2.3.0 milestone Oct 28, 2026
@CaffeinatedCoder CaffeinatedCoder added tests Adds or changes tests only (tests, probes, harnesses); no library code package/generators Affects CodoMetis.TypeKit.Generators labels Oct 28, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 4060ec9 into release/2.3.0 Oct 28, 2026
14 of 16 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the test/aspect-testing-spike branch October 28, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package/generators Affects CodoMetis.TypeKit.Generators tests Adds or changes tests only (tests, probes, harnesses); no library code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant