Skip to content

IFirstTestInAssemblyEventReceiver and IFirstTestInClassEventReceiver are called multiple times or in unexpected order in 0.50.x (regression from 0.25.21) #2916

@candhub

Description

@candhub

Version Information

  • TUnit: Issue observed in 0.50.x (e.g., 0.50.0, 0.50.1)
  • Working as expected: 0.25.21
  • OS: macOS 15.5 (arm64)
  • .NET: 9.0
  • IDE: Rider

Summary

In 0.25.21:

  • IFirstTestInAssemblyEventReceiver was called exactly once per assembly.
  • IFirstTestInClassEventReceiver was called exactly once per class.

In 0.50.x:

  • The same code results in multiple calls for the same assembly/class.
  • The call order can be interleaved with tests or occur after some tests have already run.

A gif comparing execution between 0.25.21 and 0.50.x will be attached.

Expected Behavior

  • Assembly scope: IFirstTestInAssemblyEventReceiver should be called exactly once per assembly before any test in that assembly starts.
  • Class scope: IFirstTestInClassEventReceiver should be called exactly once per class before any test in that class starts.

Actual Behavior (0.50.x)

  • Multiple calls occur for the same assembly/class.
  • Calls sometimes happen after tests in the same scope have started.
  • The order between assembly-level and class-level first events is inconsistent.

Steps to Reproduce

  1. Run with TUnit 0.25.21 → each event is called once and always before tests start.
  2. Upgrade to TUnit 0.50.x → events are called multiple times or interleaved with test output.

Requests

  1. Restore the exactly-once-per-scope guarantee in 0.50.x, or document conditions under which this guarantee does not hold.
  2. Document execution order guarantees:
    • Assembly First → Class First → tests in that class.
  3. Update documentation:
    • The current page lists the following interfaces, but does not describe
      IFirstTestInClassEventReceiver or IFirstTestInAssemblyEventReceiver:
      ITestRegisteredEventReceiver
      ITestStartEventReceiver
      ITestEndEventReceiver
      ILastTestInClassEventReceiver
      ILastTestInAssemblyEventReceiver
      ILastTestInTestSessionEventReceiver
      

Image
Image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions