Enable NativeAOT support for iOS test runner#1554
Merged
kotlarmilos merged 1 commit intodotnet:mainfrom Mar 12, 2026
Merged
Conversation
Make ThreadlessXunitTestRunner platform-generic so it can be used on iOS/tvOS/Mac Catalyst in addition to WASM. The runner uses reflection-based test discovery (ThreadlessXunitDiscoverer) which is NativeAOT-compatible, unlike XUnitTestRunner which depends on XunitFrontController for dynamic assembly loading. Changes: - ThreadlessXunitTestRunner: make ResultsFileName settable, refactor WriteResultsToFile to support file-based XML output on non-browser platforms while preserving existing WASM behavior - iOSApplicationEntryPoint: detect NativeAOT via RuntimeFeature.IsDynamicCodeSupported and automatically use ThreadlessXunitTestRunner when dynamic code is not available Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
matouskozak
approved these changes
Mar 11, 2026
Member
matouskozak
left a comment
There was a problem hiding this comment.
LGTM!
I wonder, should we add a NativeAOT test app to the set of apps we're testing so that we can validate it here? I think we also miss coverage over the regular runtime test apps as we only test libraries in xharness.
3 tasks
Member
Author
|
Yes, adding a NAOT test makes sense. The regular runtime test shouldn't differ from the library tests we already have in the CI. Created a tracking issue to add a NAOT test once we standup the runtime jobs and retrieve an app bundle. |
Member
|
The downside of the ThreadlessXunitTestRunner is that it will only run one test at a time, but you do have threads with NativeAOT. I think you could extract just the pieces that do reflection-based test discovery into a new runner. |
kotlarmilos
added a commit
to kotlarmilos/xharness
that referenced
this pull request
Mar 13, 2026
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>
kotlarmilos
added a commit
that referenced
this pull request
Mar 17, 2026
* Add NativeAOT xunit test runner with threaded execution 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 #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> * Refactor: extract CustomXunitTestRunner abstract base, rename to ReflectionBasedXunitTestRunner 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> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Make
ThreadlessXunitTestRunnerplatform-agnostic and add NativeAOT case toiOSApplicationEntryPoint. The runner uses reflection-based test discovery (ThreadlessXunitDiscoverer) which is NativeAOT-compatible, unlikeXUnitTestRunnerwhich depends onXunitFrontControllerfor dynamic assembly loading.WriteResultsToFileis refactored to support file-based xml output on non-browser platforms while preserving existing wasm behavior.Fixes dotnet/runtime#91871