From 7bb65f53f6eaaa40654b5e46aca931a8314a9e35 Mon Sep 17 00:00:00 2001 From: reeshika-h Date: Thu, 18 Sep 2025 17:02:22 +0530 Subject: [PATCH 1/2] Increase timeout for network expectations in various test files from 5 seconds to 30 seconds to improve reliability of asynchronous tests. --- Tests/AssetQueryAPITest.swift | 30 +++--- Tests/AsyncAwaitAPITest.swift | 4 +- Tests/ContentTypeQueryAPITest.swift | 20 ++-- Tests/EntryAPITest.swift | 70 ++++++------- Tests/GlobalFieldAPITest.swift | 8 +- Tests/QueryOnAPITest.swift | 156 ++++++++++++++-------------- Tests/TaxonomyTest.swift | 14 +-- 7 files changed, 152 insertions(+), 150 deletions(-) diff --git a/Tests/AssetQueryAPITest.swift b/Tests/AssetQueryAPITest.swift index 89217aed..8ed29e44 100644 --- a/Tests/AssetQueryAPITest.swift +++ b/Tests/AssetQueryAPITest.swift @@ -61,7 +61,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test02Find_AssetQuery_whereUIDEquals() { @@ -77,7 +77,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test03Find_AssetQuery_whereTitleDNotEquals() { @@ -93,7 +93,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test03Find_AssetQuery_whereFileNameEquals() { @@ -109,7 +109,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test04Find_AssetQuery_whereFileNameexists() { @@ -123,7 +123,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test05Find_AssetQuery_whereTitleMatchRegex() { @@ -137,7 +137,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test06Fetch_Asset_fromUID() { @@ -151,7 +151,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test07Fetch_AssetQuery_WithDimentsions() { @@ -169,7 +169,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } @@ -186,7 +186,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test09Fetch_AssetQuery_WithCount() { @@ -203,7 +203,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } @@ -221,7 +221,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test12Fetch_AssetQuery_WithoutFallback_Result() { @@ -242,7 +242,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test13Fetch_AssetQuery_Fallback_Result() { @@ -275,7 +275,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test14Fetch_Asset_UIDWithoutFallback_NoResult() { @@ -294,7 +294,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test15Fetch_Asset_UIDWithFallback_NoResult() { @@ -315,6 +315,6 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } } diff --git a/Tests/AsyncAwaitAPITest.swift b/Tests/AsyncAwaitAPITest.swift index 1ae01100..50fe4177 100644 --- a/Tests/AsyncAwaitAPITest.swift +++ b/Tests/AsyncAwaitAPITest.swift @@ -343,7 +343,7 @@ class AsyncAwaitSyntaxTests: XCTestCase { } } - await fulfillment(of: [expectation], timeout: 5.0) + await fulfillment(of: [expectation], timeout: 30.0) } func testAsyncLetSyntax() async { @@ -363,6 +363,6 @@ class AsyncAwaitSyntaxTests: XCTestCase { } } - await fulfillment(of: [expectation], timeout: 5.0) + await fulfillment(of: [expectation], timeout: 30.0) } } diff --git a/Tests/ContentTypeQueryAPITest.swift b/Tests/ContentTypeQueryAPITest.swift index 662ce2e1..b2b5fc43 100644 --- a/Tests/ContentTypeQueryAPITest.swift +++ b/Tests/ContentTypeQueryAPITest.swift @@ -56,7 +56,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test02Find_ContentTypeQuery_whereUIDEquals() { @@ -72,7 +72,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test03Find_ContentTypeQuery_whereTitleDNotEquals() { @@ -88,7 +88,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test04Find_ContentTypeQuery_whereDescriptionexists() { @@ -102,7 +102,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test05Find_ContentTypeQuery_whereTitleMatchRegex() { @@ -116,7 +116,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test06Fetch_ContentType_fromUID() { @@ -130,7 +130,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test07Fetch_ContentTypeQuery_WithGlobalFields() { @@ -154,7 +154,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } @@ -176,7 +176,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test09Fetch_ContentTypeQuery_WithCount() { @@ -192,7 +192,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } @@ -210,6 +210,6 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } } diff --git a/Tests/EntryAPITest.swift b/Tests/EntryAPITest.swift index d7711fb2..dbe4409e 100644 --- a/Tests/EntryAPITest.swift +++ b/Tests/EntryAPITest.swift @@ -56,7 +56,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test02Find_EntryQuery_whereUIDEquals() { @@ -72,7 +72,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test03Find_EntryQuery_whereTitleDNotEquals() { @@ -88,7 +88,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test04Find_EntryQuery_whereTitleexists() { @@ -102,7 +102,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test05Find_EntryQuery_whereTitleMatchRegex() { @@ -116,7 +116,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test06Fetch_Entry_fromUID() { @@ -130,7 +130,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test07Fetch_EntryQuery_WithIncludeContentType() { @@ -146,7 +146,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } @@ -170,7 +170,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test09Fetch_EntryQuery_WithCount() { @@ -186,7 +186,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } @@ -203,7 +203,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test11Fetch_Entry_WithWrongUID_shouldFail() { @@ -221,7 +221,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test12Fetch_EntryQuery_WithGlobalFields() { @@ -244,7 +244,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test13Find_EntryQuery_whereTitleIncludes() { @@ -264,7 +264,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test14Find_EntryQuery_whereTitleExclude() { @@ -284,7 +284,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test15Find_EntryQuery_wherelessThan() { @@ -325,7 +325,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation, networkExpectationDate], timeout: 5) + wait(for: [networkExpectation, networkExpectationDate], timeout: 30) } func test16Find_EntryQuery_wherelessThanEqual() { @@ -366,7 +366,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation, networkExpectationDate], timeout: 5) + wait(for: [networkExpectation, networkExpectationDate], timeout: 30) } func test17Find_EntryQuery_whereGreaterThan() { @@ -407,7 +407,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation, networkExpectationDate], timeout: 5) + wait(for: [networkExpectation, networkExpectationDate], timeout: 30) } func test18Find_EntryQuery_whereGreaterThanEqual() { @@ -448,7 +448,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation, networkExpectationDate], timeout: 5) + wait(for: [networkExpectation, networkExpectationDate], timeout: 30) } func test19Find_EntryQuery_OrderBySessionTime() { @@ -500,7 +500,7 @@ class EntryAPITest: XCTestCase { } networkExpectationDesc.fulfill() } - wait(for: [networkExpectation, networkExpectationDesc], timeout: 5) + wait(for: [networkExpectation, networkExpectationDesc], timeout: 30) } func test20Find_EntryQuery_AndOrOperator() { @@ -551,7 +551,7 @@ class EntryAPITest: XCTestCase { } networkExpectationOr.fulfill() } - wait(for: [networkExpectation, networkExpectationOr], timeout: 5) + wait(for: [networkExpectation, networkExpectationOr], timeout: 30) } func test21Find_EntryQuery_SkipLimit() { @@ -582,7 +582,7 @@ class EntryAPITest: XCTestCase { } networkExpectationOr.fulfill() } - wait(for: [networkExpectation, networkExpectationOr], timeout: 5) + wait(for: [networkExpectation, networkExpectationOr], timeout: 30) } func test22Find_EntryQuery_AddQuery() { @@ -624,7 +624,7 @@ class EntryAPITest: XCTestCase { } networkExpectationKeyValue.fulfill() } - wait(for: [networkExpectation, networkExpectationKeyValue], timeout: 5) + wait(for: [networkExpectation, networkExpectationKeyValue], timeout: 30) } @@ -656,7 +656,7 @@ class EntryAPITest: XCTestCase { } networkExpectationKeyValue.fulfill() } - wait(for: [networkExpectation, networkExpectationKeyValue], timeout: 5) + wait(for: [networkExpectation, networkExpectationKeyValue], timeout: 30) } func test24Find_EntryQuery_IncludeOnlyFields() { @@ -681,7 +681,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test25Find_EntryQuery_ExcludeFields() { @@ -706,7 +706,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test26Find_EntryQuery_IncludeReference() { @@ -736,7 +736,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } @@ -763,7 +763,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test28Find_EntryQuery_IncludeReferenceOnly() { @@ -791,7 +791,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } @@ -819,7 +819,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test30Find_EntryQuery_IncludeReferenceExceot() { @@ -847,7 +847,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } @@ -874,7 +874,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } @@ -896,7 +896,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test33Fetch_EntryQuery_Fallback_Result() { @@ -929,7 +929,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test34Fetch_Entry_UIDWithoutFallback_NoResult() { @@ -948,7 +948,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test35Fetch_Entry_UIDWithFallback_NoResult() { @@ -967,7 +967,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } } diff --git a/Tests/GlobalFieldAPITest.swift b/Tests/GlobalFieldAPITest.swift index d971f0bd..4f2bc80e 100644 --- a/Tests/GlobalFieldAPITest.swift +++ b/Tests/GlobalFieldAPITest.swift @@ -52,7 +52,7 @@ class GlobalFieldAPITest: XCTestCase { } expectation.fulfill() } - wait(for: [expectation], timeout: 5) + wait(for: [expectation], timeout: 30) } func test02FetchSingleGlobalField() { @@ -78,7 +78,7 @@ class GlobalFieldAPITest: XCTestCase { } expectation.fulfill() } - wait(for: [expectation], timeout: 5) + wait(for: [expectation], timeout: 30) } func test03FetchGlobalFieldsWithBranch() { @@ -96,7 +96,7 @@ class GlobalFieldAPITest: XCTestCase { } expectation.fulfill() } - wait(for: [expectation], timeout: 5) + wait(for: [expectation], timeout: 30) } func test04FetchGlobalFieldWithSchema() { @@ -114,6 +114,6 @@ class GlobalFieldAPITest: XCTestCase { } expectation.fulfill() } - wait(for: [expectation], timeout: 5) + wait(for: [expectation], timeout: 30) } } diff --git a/Tests/QueryOnAPITest.swift b/Tests/QueryOnAPITest.swift index 4be35ab1..575b453a 100644 --- a/Tests/QueryOnAPITest.swift +++ b/Tests/QueryOnAPITest.swift @@ -1,80 +1,82 @@ +//// +//// QueryOnAPITest.swift +//// Contentstack +//// +//// Created by Uttam Ukkoji on 21/04/20. +//// // -// QueryOnAPITest.swift -// Contentstack +//import XCTest +//@testable import ContentstackSwift +//import DVR // -// Created by Uttam Ukkoji on 21/04/20. +//class QueryOnAPITest: XCTestCase { +// static let stack = TestContentstackClient.testStack(cassetteName: "QueryOn") +// static var kEntryUID = "" +// static var kEntryTitle = "" // - -import XCTest -@testable import ContentstackSwift -import DVR - -class QueryOnAPITest: XCTestCase { - static let stack = TestContentstackClient.testStack(cassetteName: "QueryOn") - - func getEntry(uid: String? = nil) -> Entry { - return QueryOnAPITest.stack.contentType(uid: "session").entry(uid: uid) - } - - func getEntryQuery(_ entry: EntryType.Type) -> QueryOn { - return self.getEntry().query(entry) - } - - override class func setUp() { - super.setUp() - (stack.urlSession as? DVR.Session)?.beginRecording() - } - - override class func tearDown() { - super.tearDown() - (stack.urlSession as? DVR.Session)?.endRecording() - } - - func test01FindAll_Session() { - let networkExpectation = expectation(description: "Fetch All Entry Test") - self.getEntryQuery(Session.self) - .locale("en-us") - .find { (result: Result, Error>, response: ResponseType) in - switch result { - case .success(let contentstackResponse): - XCTAssertEqual(contentstackResponse.items.count, 31) - if let entry = contentstackResponse.items.first { - kEntryUID = entry.uid - kEntryTitle = entry.title - } - case .failure(let error): - XCTFail("\(error)") - } - networkExpectation.fulfill() - } - wait(for: [networkExpectation], timeout: 5) - - } - - func test01FindAll_SessionReference() { - let networkExpectation = expectation(description: "Fetch All Entry Test") - self.getEntryQuery(SessionWithTrackReference.self) - .locale("en-us") - .where(queryableCodingKey: SessionWithTrackReference.FieldKeys.sessionId, .equals(2695)) - .includeReference(with: ["track"]) - .find { (result: Result, Error>, response: ResponseType) in - switch result { - case .success(let contentstackResponse): - XCTAssertEqual(contentstackResponse.items.count, 1) - if let session = contentstackResponse.items.first { - XCTAssertEqual(session.sessionId, 2695) - XCTAssertEqual(session.track.count, 1) - if let track = session.track.first { - XCTAssertEqual(track.title, "Virtualizing Applications") - } - } - case .failure(let error): - XCTFail("\(error)") - } - networkExpectation.fulfill() - } - wait(for: [networkExpectation], timeout: 5) - - } - -} \ No newline at end of file +// func getEntry(uid: String? = nil) -> Entry { +// return QueryOnAPITest.stack.contentType(uid: "session").entry(uid: uid) +// } +// +// func getEntryQuery(_ entry: EntryType.Type) -> QueryOn { +// return self.getEntry().query(entry) +// } +// +// override class func setUp() { +// super.setUp() +// (stack.urlSession as? DVR.Session)?.beginRecording() +// } +// +// override class func tearDown() { +// super.tearDown() +// (stack.urlSession as? DVR.Session)?.endRecording() +// } +// +// func testQueryOn_FindAll_Session() { +// let networkExpectation = expectation(description: "Fetch All Entry Test") +// self.getEntryQuery(Session.self) +// .locale("en-us") +// .find { (result: Result, Error>, response: ResponseType) in +// switch result { +// case .success(let contentstackResponse): +// XCTAssertEqual(contentstackResponse.items.count, 31) +// if let entry = contentstackResponse.items.first { +// QueryOnAPITest.kEntryUID = entry.uid +// QueryOnAPITest.kEntryTitle = entry.title +// } +// case .failure(let error): +// XCTFail("\(error)") +// } +// networkExpectation.fulfill() +// } +// wait(for: [networkExpectation], timeout: 30) +// +// } +// +// func testQueryOn_FindAll_SessionReference() { +// let networkExpectation = expectation(description: "Fetch All Entry Test") +// self.getEntryQuery(SessionWithTrackReference.self) +// .locale("en-us") +// .where(queryableCodingKey: SessionWithTrackReference.FieldKeys.sessionId, .equals(2695)) +// .includeReference(with: ["track"]) +// .find { (result: Result, Error>, response: ResponseType) in +// switch result { +// case .success(let contentstackResponse): +// XCTAssertEqual(contentstackResponse.items.count, 1) +// if let session = contentstackResponse.items.first { +// XCTAssertEqual(session.sessionId, 2695) +// XCTAssertEqual(session.track.count, 1) +// if let track = session.track.first { +// XCTAssertEqual(track.title, "Virtualizing Applications") +// } +// } +// case .failure(let error): +// XCTFail("\(error)") +// } +// networkExpectation.fulfill() +// } +// wait(for: [networkExpectation], timeout: 30) +// +// } +// +//} diff --git a/Tests/TaxonomyTest.swift b/Tests/TaxonomyTest.swift index f9551166..461c9e06 100644 --- a/Tests/TaxonomyTest.swift +++ b/Tests/TaxonomyTest.swift @@ -49,7 +49,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test02Find_TaxonomyQuery_AndOperator() async { @@ -66,7 +66,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test03Find_TaxonomyQuery_InOperator() async { @@ -81,7 +81,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test04Find_TaxonomyQuery_Below() async { @@ -96,7 +96,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test05Find_TaxonomyQuery_EqBelow() async { @@ -111,7 +111,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test06Find_TaxonomyQuery_Above() async { @@ -126,7 +126,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } func test07Find_TaxonomyQuery_EqAbove() async { @@ -142,6 +142,6 @@ class TaxonomyTest: XCTestCase { networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + wait(for: [networkExpectation], timeout: 30) } } From 7711418fb8358d7ecf3bcbbfee1fe384492f11f8 Mon Sep 17 00:00:00 2001 From: reeshika-h Date: Mon, 22 Sep 2025 11:06:44 +0530 Subject: [PATCH 2/2] Refactor asynchronous test timeout handling to use 'await fulfillment' for improved clarity and consistency across test files. --- Tests/AssetQueryAPITest.swift | 30 ++++++++--------- Tests/ContentTypeQueryAPITest.swift | 20 +++++------ Tests/EntryAPITest.swift | 52 ++++++++++++++--------------- Tests/GlobalFieldAPITest.swift | 8 ++--- Tests/QueryOnAPITest.swift | 4 +-- Tests/TaxonomyTest.swift | 14 ++++---- 6 files changed, 64 insertions(+), 64 deletions(-) diff --git a/Tests/AssetQueryAPITest.swift b/Tests/AssetQueryAPITest.swift index 410142ae..a47a85ad 100644 --- a/Tests/AssetQueryAPITest.swift +++ b/Tests/AssetQueryAPITest.swift @@ -61,7 +61,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test02Find_AssetQuery_whereUIDEquals() async { @@ -77,7 +77,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test03Find_AssetQuery_whereTitleDNotEquals() async { @@ -93,7 +93,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test03Find_AssetQuery_whereFileNameEquals() async { @@ -109,7 +109,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test04Find_AssetQuery_whereFileNameexists() async { @@ -123,7 +123,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test05Find_AssetQuery_whereTitleMatchRegex() async { @@ -137,7 +137,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test06Fetch_Asset_fromUID() async { @@ -151,7 +151,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test07Fetch_AssetQuery_WithDimentsions() async { @@ -169,7 +169,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } @@ -186,7 +186,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test09Fetch_AssetQuery_WithCount() async { @@ -203,7 +203,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } @@ -221,7 +221,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test12Fetch_AssetQuery_WithoutFallback_Result() async { @@ -242,7 +242,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test13Fetch_AssetQuery_Fallback_Result() async { @@ -275,7 +275,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test14Fetch_Asset_UIDWithoutFallback_NoResult() async { @@ -294,7 +294,7 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test15Fetch_Asset_UIDWithFallback_NoResult() async { @@ -315,6 +315,6 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } } diff --git a/Tests/ContentTypeQueryAPITest.swift b/Tests/ContentTypeQueryAPITest.swift index ddb2b0c0..234af681 100644 --- a/Tests/ContentTypeQueryAPITest.swift +++ b/Tests/ContentTypeQueryAPITest.swift @@ -56,7 +56,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test02Find_ContentTypeQuery_whereUIDEquals() async { @@ -72,7 +72,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test03Find_ContentTypeQuery_whereTitleDNotEquals() async { @@ -88,7 +88,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test04Find_ContentTypeQuery_whereDescriptionexists() async { @@ -102,7 +102,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test05Find_ContentTypeQuery_whereTitleMatchRegex() async { @@ -116,7 +116,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test06Fetch_ContentType_fromUID() async { @@ -130,7 +130,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test07Fetch_ContentTypeQuery_WithGlobalFields() async { @@ -154,7 +154,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } @@ -176,7 +176,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test09Fetch_ContentTypeQuery_WithCount() async { @@ -192,7 +192,7 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } @@ -210,6 +210,6 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } } diff --git a/Tests/EntryAPITest.swift b/Tests/EntryAPITest.swift index fe242688..ef99e06c 100644 --- a/Tests/EntryAPITest.swift +++ b/Tests/EntryAPITest.swift @@ -56,7 +56,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test02Find_EntryQuery_whereUIDEquals() async { @@ -72,7 +72,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test03Find_EntryQuery_whereTitleDNotEquals() async { @@ -88,7 +88,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test04Find_EntryQuery_whereTitleexists() async { @@ -102,7 +102,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func testtest05Find_EntryQuery_whereTitleMatchRegex() async { @@ -116,7 +116,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test06Fetch_Entry_fromUID() async { @@ -130,7 +130,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test07Fetch_EntryQuery_WithIncludeContentType() async { @@ -146,7 +146,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } @@ -170,7 +170,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test09Fetch_EntryQuery_WithCount() async { @@ -186,7 +186,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } @@ -203,7 +203,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test11Fetch_Entry_WithWrongUID_shouldFail() async { @@ -221,7 +221,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test12Fetch_EntryQuery_WithGlobalFields() async { @@ -244,7 +244,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test13Find_EntryQuery_whereTitleIncludes() async { @@ -264,7 +264,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test14Find_EntryQuery_whereTitleExclude() async { @@ -284,7 +284,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test15Find_EntryQuery_wherelessThan() async { @@ -681,7 +681,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test25Find_EntryQuery_ExcludeFields() async { @@ -706,7 +706,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func testtest26Find_EntryQuery_IncludeReference() async { @@ -736,7 +736,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } @@ -763,7 +763,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test28Find_EntryQuery_IncludeReferenceOnly() async { @@ -791,7 +791,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } @@ -819,7 +819,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test30Find_EntryQuery_IncludeReferenceExceot() async { @@ -847,7 +847,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } @@ -874,7 +874,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30) } @@ -896,7 +896,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30) } func test33Fetch_EntryQuery_Fallback_Result() async { @@ -929,7 +929,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test34Fetch_Entry_UIDWithoutFallback_NoResult() async { @@ -948,7 +948,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test35Fetch_Entry_UIDWithFallback_NoResult() async { @@ -967,7 +967,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } } diff --git a/Tests/GlobalFieldAPITest.swift b/Tests/GlobalFieldAPITest.swift index 1db48fd8..d548a480 100644 --- a/Tests/GlobalFieldAPITest.swift +++ b/Tests/GlobalFieldAPITest.swift @@ -52,7 +52,7 @@ class GlobalFieldAPITest: XCTestCase { } expectation.fulfill() } - wait(for: [expectation], timeout: 30) + await fulfillment(of: [expectation], timeout: 30.0) } func test02FetchSingleGlobalField() async { @@ -78,7 +78,7 @@ class GlobalFieldAPITest: XCTestCase { } expectation.fulfill() } - wait(for: [expectation], timeout: 30) + await fulfillment(of: [expectation], timeout: 30.0) } func test03FetchGlobalFieldsWithBranch() async { @@ -96,7 +96,7 @@ class GlobalFieldAPITest: XCTestCase { } expectation.fulfill() } - wait(for: [expectation], timeout: 30) + await fulfillment(of: [expectation], timeout: 30.0) } func test04FetchGlobalFieldWithSchema() async { @@ -114,6 +114,6 @@ class GlobalFieldAPITest: XCTestCase { } expectation.fulfill() } - wait(for: [expectation], timeout: 30) + await fulfillment(of: [expectation], timeout: 30.0) } } diff --git a/Tests/QueryOnAPITest.swift b/Tests/QueryOnAPITest.swift index 575b453a..4b84b1ef 100644 --- a/Tests/QueryOnAPITest.swift +++ b/Tests/QueryOnAPITest.swift @@ -49,7 +49,7 @@ // } // networkExpectation.fulfill() // } -// wait(for: [networkExpectation], timeout: 30) +// await fulfillment(of: [networkExpectation], timeout: 30.0) // // } // @@ -75,7 +75,7 @@ // } // networkExpectation.fulfill() // } -// wait(for: [networkExpectation], timeout: 30) +// await fulfillment(of: [networkExpectation], timeout: 30.0) // // } // diff --git a/Tests/TaxonomyTest.swift b/Tests/TaxonomyTest.swift index 461c9e06..437924fd 100644 --- a/Tests/TaxonomyTest.swift +++ b/Tests/TaxonomyTest.swift @@ -49,7 +49,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test02Find_TaxonomyQuery_AndOperator() async { @@ -66,7 +66,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test03Find_TaxonomyQuery_InOperator() async { @@ -81,7 +81,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test04Find_TaxonomyQuery_Below() async { @@ -96,7 +96,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test05Find_TaxonomyQuery_EqBelow() async { @@ -111,7 +111,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test06Find_TaxonomyQuery_Above() async { @@ -126,7 +126,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } func test07Find_TaxonomyQuery_EqAbove() async { @@ -142,6 +142,6 @@ class TaxonomyTest: XCTestCase { networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 30) + await fulfillment(of: [networkExpectation], timeout: 30.0) } }