Skip to content

Faults() with several starts reports a fault as uncaught when only another start can trigger it #35

Closed

Description

@Mpdreamz

EntitySpec.Faults() throws when an entity has several starts and a declared fault can only fire from one of them. The fault is caught from the start where it can happen, but it reads as uncaught from the others.

What happened

A payment has two kinds, card and invoice, and some operations only apply to one kind. The spec is given one start of each kind with .From(card, invoice). It declares a fault for each kind, such as "Charge charges an invoice" and "Capture forgets the receipt". Faults() fails with:

No requirement detects these faults: Charge charges an invoice, SendInvoice loses the number, MarkPaid reopens

Swapping the order to .From(invoice, card) makes the other kind's faults the uncaught ones. Every fault is caught when the spec has a single start.

Cause

EntitySpec.Faults (src/Nullean.Entities.CsCheck/EntitySpec.cs, around line 370) loops over Starts() and calls Build(start, autoFaults: true).Spec.Faults(..., throwOnUncaught: ...) once per start. It throws on the first start that does not catch every fault, including faults that start never triggers.

What would you like instead

A declared fault counts as caught when any start catches it, and the run fails only for a fault that no start catches. A fault that never fires from any start would ideally be reported as such ("never triggered"), not as "uncaught".

Workaround

One spec per start, each with only the faults that start can reach.

Version or commit

main at f12a258 (0.1.1 on NuGet).

Estimated work: half a day.

Activity

  1. Mpdreamz commented on Nov 19, 2026

    @Mpdreamz
    ContributorAuthor

    Reproduced and fixed in #104. EntitySpec.Faults()/SampleFaults() let CsCheck throw on uncaught faults separately for each start, so a fault only one start can trigger (the other start never reaches the state) failed the run even though another start caught it. Now all starts run first, and it throws only for faults uncaught from every start. The new test failed before the fix with No requirement detects these faults. I ran it on net10.0 only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA defect fixed (patch)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions