diff --git a/Package.swift b/Package.swift index 3309ad3..a341786 100644 --- a/Package.swift +++ b/Package.swift @@ -12,9 +12,9 @@ import PackageDescription #if swift(<6) -let swiftConcurrency: SwiftSetting = .enableExperimentalFeature("SwiftConcurrency") +let swiftConcurrency: SwiftSetting = .enableExperimentalFeature("StrictConcurrency") #else -let swiftConcurrency: SwiftSetting = .enableUpcomingFeature("SwiftConcurrency") +let swiftConcurrency: SwiftSetting = .enableUpcomingFeature("StrictConcurrency") #endif diff --git a/Sources/XCTestApp/TestAppTestCase.swift b/Sources/XCTestApp/TestAppTestCase.swift index 37a7802..943ff3d 100644 --- a/Sources/XCTestApp/TestAppTestCase.swift +++ b/Sources/XCTestApp/TestAppTestCase.swift @@ -10,6 +10,7 @@ /// A collection of test cases that can be executed in an ``TestAppView``. public protocol TestAppTestCase: Identifiable { /// Implement this method to run all the tests that should be executed. + @MainActor func runTests() async throws } diff --git a/Sources/XCTestExtensions/XCTAssertThrowsErrorAsync.swift b/Sources/XCTestExtensions/XCTAssertThrowsErrorAsync.swift index c93cbb7..21a96a6 100644 --- a/Sources/XCTestExtensions/XCTAssertThrowsErrorAsync.swift +++ b/Sources/XCTestExtensions/XCTAssertThrowsErrorAsync.swift @@ -20,11 +20,11 @@ import XCTest /// - line: The line number where the failure occurs. The default is the line number where you call this function. /// - errorHandler: An optional handler for errors that expression throws. public func XCTAssertThrowsErrorAsync( - _ expression: @autoclosure () async throws -> T, - _ message: @autoclosure () -> String = "", + _ expression: @autoclosure @Sendable () async throws -> T, + _ message: @autoclosure @Sendable () -> String = "", file: StaticString = #filePath, line: UInt = #line, - _ errorHandler: (Error) throws -> Void = { _ in } + _ errorHandler: @Sendable (Error) throws -> Void = { _ in } ) async rethrows { do { _ = try await expression() diff --git a/Sources/XCTestExtensions/XCTestCase+DisablePasswordAutofill.swift b/Sources/XCTestExtensions/XCTestCase+DisablePasswordAutofill.swift index 2b23e4f..c748552 100644 --- a/Sources/XCTestExtensions/XCTestCase+DisablePasswordAutofill.swift +++ b/Sources/XCTestExtensions/XCTestCase+DisablePasswordAutofill.swift @@ -33,6 +33,7 @@ extension XCTestCase { @available(macOS, unavailable) @available(tvOS, unavailable) @available(visionOS, unavailable) + @MainActor public func disablePasswordAutofill() throws { let settingsApp = XCUIApplication(bundleIdentifier: "com.apple.Preferences") settingsApp.terminate() diff --git a/Sources/XCTestExtensions/XCUIElement+TextEntry.swift b/Sources/XCTestExtensions/XCUIElement+TextEntry.swift index 1a6501c..1a515fd 100644 --- a/Sources/XCTestExtensions/XCUIElement+TextEntry.swift +++ b/Sources/XCTestExtensions/XCUIElement+TextEntry.swift @@ -13,7 +13,7 @@ import XCTest /// An internal flag that is used to test the flaky simulator text entry behavior in the iOS simulator. /// /// Do not use this flag outside of the UI tests in the ``XCTestExtensions`` target! -var simulateFlakySimulatorTextEntry = false +@MainActor var simulateFlakySimulatorTextEntry = false extension XCUIElement { diff --git a/Tests/UITests/TestAppUITests/XCTestExtensionsTests.swift b/Tests/UITests/TestAppUITests/XCTestExtensionsTests.swift index 8862b43..47e5dbb 100644 --- a/Tests/UITests/TestAppUITests/XCTestExtensionsTests.swift +++ b/Tests/UITests/TestAppUITests/XCTestExtensionsTests.swift @@ -59,6 +59,7 @@ class XCTestExtensionsTests: XCTestCase { XCTAssert(app.staticTexts["No secure text set ..."].waitForExistence(timeout: 5)) } + @MainActor func testDisablePasswordAutofill() throws { #if os(iOS) try disablePasswordAutofill() @@ -75,6 +76,7 @@ class XCTestExtensionsTests: XCTestCase { try app.callTextEntryExtensions() } + @MainActor func testFlakyTextEntry() throws { let app = XCUIApplication() app.launch()