From 8c8cf1ec9ee88cd25bd074ef69320254ae570d83 Mon Sep 17 00:00:00 2001 From: Andreas Bauer Date: Mon, 15 Jul 2024 10:47:06 +0200 Subject: [PATCH] Update usage of XCTRuntimePrecondition --- .../Communication/ModuleCommunicationTests.swift | 6 ++++-- Tests/SpeziTests/ModuleTests/ModuleTests.swift | 3 ++- .../StandardTests/StandardUnfulfilledConstraintTests.swift | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Tests/SpeziTests/CapabilityTests/Communication/ModuleCommunicationTests.swift b/Tests/SpeziTests/CapabilityTests/Communication/ModuleCommunicationTests.swift index fc0968f9..1501a7de 100644 --- a/Tests/SpeziTests/CapabilityTests/Communication/ModuleCommunicationTests.swift +++ b/Tests/SpeziTests/CapabilityTests/Communication/ModuleCommunicationTests.swift @@ -74,13 +74,15 @@ final class ModuleCommunicationTests: XCTestCase { func testIllegalAccess() throws { let delegate = TestApplicationDelegate() - try XCTRuntimePrecondition { + try XCTRuntimePrecondition { @MainActor in + try? await Task.sleep(for: .milliseconds(0)) _ = Self.collectModule.strings } _ = delegate.spezi // ensure init - try XCTRuntimePrecondition { + try XCTRuntimePrecondition { @MainActor in + try? await Task.sleep(for: .milliseconds(0)) Self.provideModule.numMaybe2 = 12 } } diff --git a/Tests/SpeziTests/ModuleTests/ModuleTests.swift b/Tests/SpeziTests/ModuleTests/ModuleTests.swift index 4772c039..63117628 100644 --- a/Tests/SpeziTests/ModuleTests/ModuleTests.swift +++ b/Tests/SpeziTests/ModuleTests/ModuleTests.swift @@ -74,7 +74,8 @@ final class ModuleTests: XCTestCase { @MainActor func testPreviewModifierOnlyWithinPreview() throws { - try XCTRuntimePrecondition { + try XCTRuntimePrecondition { @MainActor in + try? await Task.sleep(for: .milliseconds(0)) _ = Text("Spezi") .previewWith { TestModule() diff --git a/Tests/SpeziTests/StandardTests/StandardUnfulfilledConstraintTests.swift b/Tests/SpeziTests/StandardTests/StandardUnfulfilledConstraintTests.swift index 0684dd80..fd0307af 100644 --- a/Tests/SpeziTests/StandardTests/StandardUnfulfilledConstraintTests.swift +++ b/Tests/SpeziTests/StandardTests/StandardUnfulfilledConstraintTests.swift @@ -42,7 +42,7 @@ final class StandardUnfulfilledConstraintTests: XCTestCase { func testStandardUnfulfilledConstraint() throws { let standardCUTestApplicationDelegate = StandardUCTestApplicationDelegate() try XCTRuntimePrecondition(timeout: 0.5) { - _ = standardCUTestApplicationDelegate.spezi + _ = await standardCUTestApplicationDelegate.spezi } } }