Support for hosting UI automation tests
Description
Looks that Swift Testing does not support UITest at the moment. Any plans to support UITest in the future?
Certainly, there are some differences in testing APIs between unit testing and UI testing, But supporting UITest would help maintain a unified and friendly testing experience and test ecosystem.
Expected behavior
Use Swift testing in UITest
Actual behavior
Can not import Testing in UITest Target
Steps to reproduce
No response
swift-testing version/commit hash
No response
Swift & OS version (output of swift --version && uname -a)
No response
Thanks for bringing this up, @HollyFoxtel!
Swift Testing itself is primarily concerned with defining tests, running them, and getting their results. The exactly nature of those tests, i.e. the steps they perform, Swift Testing is agnostic about.
On Apple platforms, XCTest provides UI automation APIs like XCUIApplication for automating apps in its (closed-source) framework included in Xcode. Currently, those APIs do not behave correctly when used in Swift Testing tests, so in Xcode 16 Beta, the build system shows the error you mentioned when attempting to import Testing in any UI test target. To allow using XCTest's UI automation features within Swift Testing tests, work will be needed in Apple's proprietary XCTest framework. Since that project is separate, I encourage you to file a Feedback with Apple requesting this functionality.
Beyond that, it is also likely that additional supporting functionality will need to be added here, in Swift Testing, to allow UI testing systems to work properly. For example, there may need to be additional controls over parallelization or result reporting. These kinds of enhancements need to be explored and defined, but they would potentially be relevant/applicable to any UI automation system, not just XCTest UI automation. In general, we do want Swift Testing to be capable of hosting UI automation style tests, although this is not something which we have the capacity to focus on for its initial release aligned with Swift 6. We will keep this GitHub issue open to track the aspects of this work which directly affect Swift Testing.
Tracked internally at Apple with rdar://95593221.