Skip to content

[Executors] Run the UI tests of a class in a row between its class hooks - #134

Merged
Nice3point merged 7 commits into
developfrom
executors/132-run-class-hooks-in-class-order
Oct 29, 2026
Merged

Nice3point merged 7 commits into
developfrom
executors/132-run-class-hooks-in-class-order

Conversation

@Nice3point

@Nice3point Nice3point commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Summary of the Pull Request

What is this about:

The UI tests of a class run one after another, between the class hooks of that class.

Description:

What changed

  • Inside Revit, [Before(Class)] of a RevitApiUiTest class runs when the test host executes the first test of the class.
    A library [BeforeEvery(Class)] hook with the lowest order and no timeout waits for that execution.
    The hooks of the class run after it with their own timeouts.
  • In the test host, every UI test gets a NotInParallel constraint with one shared key instead of RevitUiParallelLimit.
    TUnit runs keyed tests one at a time, class by class, in parallel with the other tests.
    A key a test already declares joins the UI key in one constraint.
  • On .NET Framework, RevitApiTest and RevitApiUiTest declare [HookExecutor(typeof(...))].
    TUnit ignored the generic class attribute there.
    The [Before(Class)] and [After(Class)] hooks of a derived class ran outside the Revit thread: on a pool thread for RevitApiTest, in the test host process for RevitApiUiTest.
  • TUnit 1.76.45. On 1.73.19, --fail-fast crashed the test host in TestScheduler.ProcessDynamicTestQueueAsync.

Three UI classes, each opening a document in [Before(Class)] and closing it in [After(Class)], on Revit 2027:

Before After
All three [Before(Class)] hooks run before the first test, 3 documents open Each class opens its document right before its first test, 1 open
Tests of the classes interleave, a document is open until its last test before A → A.* → after A → before B → …
A [Before(Class)] with [Timeout(3000)] times out behind the other hooks The hook gets an uncancelled token
With --maximum-parallel-tests 2, RevitApiTest tests wait for every UI test RevitApiTest tests run while Revit starts; the run takes 30 s, not 47 s

Where to look

  • RevitUiThreadExecutor.AddUiConstraint adds the UI key to the keys of the NotInParallel constraint a test declares.
    TUnit reads only the first NotInParallel constraint of a test.
    With a second constraint, TUnit ignores either the UI key or the keys of the user.
    The method does not change a global [NotInParallel]: TUnit runs such a test alone at the end.
  • The first test of a class reports the duration of its [Before(Class)] hooks, as TUnit reports it outside Revit.

How verified

  • Build: Release.R21, Release.R24, Release.R27, zero warnings, zero errors.
  • Tests:
Revit Passed Skipped Failed
2027 127 3 0
2025 148 3 0
2024, net48 148 3 0
  • ClassHookTests and ClassHookUiTests fail on Revit 2024 without the .NET Framework change, 2 of 2.
  • FirstClassLifetimeUiTests and SecondClassLifetimeUiTests fail without the UI order change, 6 of 6 in two runs.
  • Manually, on Revit 2027 and 2024: the three-class scenario above, a filter on one test of a class, and --fail-fast with a failing UI test.
  • --fail-fast skips the 7 unstarted tests and runs no hook of the unreached classes.
  • Not covered: Revit 2021 to 2023 and 2026 at run time.

Open questions

  • RevitUiParallelLimit is public. No UI test uses it.
    The options: no change, [Obsolete], or removal in a major version.

Quality Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@Nice3point Nice3point added bug 🐛 An unexpected issue that highlights incorrect behavior executors 🎬 Revit thread executors and the test lifecycle labels Oct 29, 2026
@Nice3point
Nice3point marked this pull request as ready for review October 29, 2026 17:52
Copilot AI balanced review requested due to automatic review settings October 29, 2026 17:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@Nice3point
Nice3point merged commit 6487aab into develop Oct 29, 2026
1 check passed
@Nice3point
Nice3point deleted the executors/132-run-class-hooks-in-class-order branch October 29, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐛 An unexpected issue that highlights incorrect behavior executors 🎬 Revit thread executors and the test lifecycle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants