Skip to content

Add NativeAOT xunit test runner with threaded execution#1560

Open
kotlarmilos wants to merge 2 commits intodotnet:mainfrom
kotlarmilos:feature/native-aot-test-runner
Open

Add NativeAOT xunit test runner with threaded execution#1560
kotlarmilos wants to merge 2 commits intodotnet:mainfrom
kotlarmilos:feature/native-aot-test-runner

Conversation

@kotlarmilos
Copy link
Member

@kotlarmilos kotlarmilos commented Mar 13, 2026

Description

Introduce NativeAotXunitTestRunner that extends ThreadlessXunitTestRunner with parallel test execution support and file-based result output. ThreadlessXunitTestRunner uses reflection-based discovery (NativeAOT-safe) but forces single-threaded execution. Since NativeAOT has threads available, the new runner overrides the configuration to allow parallel test collections.

Changes

  • Add NativeAotXunitTestRunner extending ThreadlessXunitTestRunner with configurable MaxParallelThreads and ParallelizeTestCollections
  • Extract virtual CreateConfiguration() and RunnerDisplayName from ThreadlessXunitTestRunner for extensibility
  • Revert Enable NativeAOT support for iOS test runner #1554 changes to ThreadlessXunitTestRunner, keeping it WASM-only as originally intended

Introduce NativeAotXunitTestRunner that extends ThreadlessXunitTestRunner
with parallel test execution support and file-based result output.
ThreadlessXunitTestRunner uses reflection-based discovery (NativeAOT-safe)
but forces single-threaded execution. The new runner overrides the
configuration to allow parallel test collections since NativeAOT has
threads available.

- Add NativeAotXunitTestRunner extending ThreadlessXunitTestRunner with
  configurable MaxParallelThreads and ParallelizeTestCollections
- Extract virtual CreateConfiguration() and RunnerDisplayName from
  ThreadlessXunitTestRunner for extensibility
- Revert PR dotnet#1554 changes to ThreadlessXunitTestRunner, keeping it
  WASM-only as originally intended
- Update iOS and Android entry points to use NativeAotXunitTestRunner
  when RuntimeFeature.IsDynamicCodeSupported is false

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
/// Xunit test runner for NativeAOT environments. Extends ThreadlessXunitTestRunner
/// with parallel test execution support and file-based result output.
/// </summary>
internal class NativeAotXunitTestRunner : ThreadlessXunitTestRunner
Copy link
Member

Choose a reason for hiding this comment

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

call this ReflectionBasedXunitTestRunner or something else that is not directly tied to NativeAOT

Copy link
Member

Choose a reason for hiding this comment

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

I think you could make this an abstract class CustomXunitTestRunner and then make ThreadlessXunitTestRunner and ReflectionBasedXunitTestRunner concrete implementations of that.

This would avoid the weird conceptual situation where ReflectionBasedXunitTestRunner derives from ThreadlessXunitTestRunner

…ectionBasedXunitTestRunner

Address review feedback:
- Rename NativeAotXunitTestRunner to ReflectionBasedXunitTestRunner
- Extract shared reflection-based discovery logic into abstract
  CustomXunitTestRunner base class
- Make ThreadlessXunitTestRunner and ReflectionBasedXunitTestRunner
  concrete implementations of CustomXunitTestRunner

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants