From 8c124d5f363580db36b5bee06b50ac776361f918 Mon Sep 17 00:00:00 2001 From: radude89 Date: Wed, 14 Aug 2024 10:41:26 +0300 Subject: [PATCH] Fix all tests in Xcode 16 beta 5 --- ...ilsDuplicateVerifierIntegrationTests.swift | 7 ++- .../Views/ConfirmPlayersViewController.swift | 3 +- .../ConfirmPlayersViewControllerTests.swift | 15 +++--- .../ConfirmPlayersViewModelTests.swift | 7 ++- FootballGather/Snapshots/Snapshots.swift | 54 +++++++++---------- .../UITests/Helpers/PlayersFinder.swift | 1 + .../UITests/Helpers/UITestCase.swift | 20 +++---- .../UseCases/Add/AddPlayerUITests.swift | 17 +++--- .../Confirmation/ConfirmPlayersUITests.swift | 19 ++++--- .../Details/PlayerDetailsUITests.swift | 9 ++-- .../UseCases/Edit/EditPlayerUITests.swift | 13 +++-- .../UseCases/Gather/GatherUITests.swift | 15 +++--- .../UseCases/History/HistoryViewUITests.swift | 2 +- .../UseCases/List/PlayerListUITests.swift | 2 +- 14 files changed, 90 insertions(+), 94 deletions(-) diff --git a/FootballGather/Packages/UseCases/Details/PlayerDetails/Tests/PlayerDetailsIntegrationTests/PlayerDetailsDuplicateVerifierIntegrationTests.swift b/FootballGather/Packages/UseCases/Details/PlayerDetails/Tests/PlayerDetailsIntegrationTests/PlayerDetailsDuplicateVerifierIntegrationTests.swift index 68c3292..8a95993 100644 --- a/FootballGather/Packages/UseCases/Details/PlayerDetails/Tests/PlayerDetailsIntegrationTests/PlayerDetailsDuplicateVerifierIntegrationTests.swift +++ b/FootballGather/Packages/UseCases/Details/PlayerDetails/Tests/PlayerDetailsIntegrationTests/PlayerDetailsDuplicateVerifierIntegrationTests.swift @@ -16,10 +16,9 @@ final class PlayerDetailsDuplicateVerifierIntegrationTests: XCTestCase { private let allPositions = Player.Position.allCases private let allSkills = Player.Skill.allCases - @MainActor - override func setUp() { - super.setUp() - sut = PlayerDetailsDuplicateVerifier(storage: Mocks.storage) + override func setUp() async throws { + try await super.setUp() + sut = await PlayerDetailsDuplicateVerifier(storage: Mocks.storage) } override func tearDown() { diff --git a/FootballGather/Packages/UseCases/TeamSelection/TeamSelection/Sources/TeamSelection/Views/ConfirmPlayersViewController.swift b/FootballGather/Packages/UseCases/TeamSelection/TeamSelection/Sources/TeamSelection/Views/ConfirmPlayersViewController.swift index 3e3d226..4049aa5 100644 --- a/FootballGather/Packages/UseCases/TeamSelection/TeamSelection/Sources/TeamSelection/Views/ConfirmPlayersViewController.swift +++ b/FootballGather/Packages/UseCases/TeamSelection/TeamSelection/Sources/TeamSelection/Views/ConfirmPlayersViewController.swift @@ -13,7 +13,8 @@ import TeamSelectionAssets // MARK: - ConfirmPlayersViewController -final class ConfirmPlayersViewController: UIViewController { +@MainActor +final class ConfirmPlayersViewController: UIViewController, @unchecked Sendable { // MARK: - Properties diff --git a/FootballGather/Packages/UseCases/TeamSelection/TeamSelection/Tests/TeamSelectionTests/ConfirmPlayersViewControllerTests.swift b/FootballGather/Packages/UseCases/TeamSelection/TeamSelection/Tests/TeamSelectionTests/ConfirmPlayersViewControllerTests.swift index d915df4..fab87ab 100644 --- a/FootballGather/Packages/UseCases/TeamSelection/TeamSelection/Tests/TeamSelectionTests/ConfirmPlayersViewControllerTests.swift +++ b/FootballGather/Packages/UseCases/TeamSelection/TeamSelection/Tests/TeamSelectionTests/ConfirmPlayersViewControllerTests.swift @@ -16,13 +16,15 @@ final class ConfirmPlayersViewControllerTests: XCTestCase { private let playersCount = Player.demoPlayers.count private var gatherCoordinator: MockGatherCoordinator! - @MainActor - override func setUp() { - super.setUp() - + override func setUp() async throws { + try await super.setUp() + gatherCoordinator = MockGatherCoordinator() - sut = ConfirmPlayersViewController(players: .demoPlayers, gatherCoordinator: gatherCoordinator) - sut.loadViewIfNeeded() + sut = await ConfirmPlayersViewController( + players: .demoPlayers, + gatherCoordinator: gatherCoordinator + ) + await sut.loadViewIfNeeded() } override func tearDown() { @@ -301,6 +303,7 @@ final class ConfirmPlayersViewControllerTests: XCTestCase { } private final class MockGatherCoordinator: GatherCoordinatable { + @MainActor func startGather(from parent: UIViewController, playersTeams: [Team : [Player]], animated: Bool) { } } diff --git a/FootballGather/Packages/UseCases/TeamSelection/TeamSelection/Tests/TeamSelectionTests/ConfirmPlayersViewModelTests.swift b/FootballGather/Packages/UseCases/TeamSelection/TeamSelection/Tests/TeamSelectionTests/ConfirmPlayersViewModelTests.swift index c11fd63..6150d3b 100644 --- a/FootballGather/Packages/UseCases/TeamSelection/TeamSelection/Tests/TeamSelectionTests/ConfirmPlayersViewModelTests.swift +++ b/FootballGather/Packages/UseCases/TeamSelection/TeamSelection/Tests/TeamSelectionTests/ConfirmPlayersViewModelTests.swift @@ -14,10 +14,9 @@ final class ConfirmPlayersViewModelTests: XCTestCase { private var sut: ConfirmPlayersViewModel! private let players = Player.demoPlayers - @MainActor - override func setUp() { - super.setUp() - sut = ConfirmPlayersViewModel(players: players) + override func setUp() async throws { + try await super.setUp() + sut = await ConfirmPlayersViewModel(players: players) } override func tearDown() { diff --git a/FootballGather/Snapshots/Snapshots.swift b/FootballGather/Snapshots/Snapshots.swift index 11a3dc2..1db8fa9 100644 --- a/FootballGather/Snapshots/Snapshots.swift +++ b/FootballGather/Snapshots/Snapshots.swift @@ -12,45 +12,31 @@ import PlayerListAssets import TeamSelectionAssets import GatherAssets -final class Snapshots: XCTestCase { +final class Snapshots: XCTestCase, @unchecked Sendable { // MARK: - Setup private var app: XCUIApplication! - @MainActor - override func setUpWithError() throws { - try super.setUpWithError() - + override func setUp() { + super.setUp() continueAfterFailure = false - setupApp() - app.launch() - } - - @MainActor - private func setupApp() { app = XCUIApplication() - setupLaunchArguments() - setupSnapshot(app) - } - - @MainActor - private func setupLaunchArguments() { - app.launchArguments = ["-uitests"] - app.launchArguments.append(Command.populateStorage.rawValue) - addUIInterruptionMonitor() } - - @MainActor - override func tearDownWithError() throws { - app.terminate() - try super.tearDownWithError() + + override func tearDown() async throws { + await app.terminate() + try await super.tearDown() } // MARK: - Snapshots @MainActor func testSnapshots() throws { + // Setup and launch the app + setupApp() + app.launch() + // Landing screen - player list takeSnapshot(named: "01-player-list") @@ -84,6 +70,17 @@ final class Snapshots: XCTestCase { @MainActor private extension Snapshots { + func setupApp() { + setupLaunchArguments() + addUIInterruptionMonitor() + setupSnapshot(app) + } + + func setupLaunchArguments() { + app.launchArguments = ["-uitests"] + app.launchArguments.append(Command.populateStorage.rawValue) + } + func takeSnapshot(named name: String) { var snapshotName = name @@ -126,9 +123,10 @@ private extension Snapshots { private extension Snapshots { func addUIInterruptionMonitor() { addUIInterruptionMonitor( - withDescription: "Notification alert") { [weak self] alert in - return self?.handleAlertPermissions(alert) ?? false - } + withDescription: "Notification alert" + ) { [weak self] alert in + self?.handleAlertPermissions(alert) ?? false + } } func handleAlertPermissions(_ alert: XCUIElement) -> Bool { diff --git a/FootballGather/UITests/Helpers/PlayersFinder.swift b/FootballGather/UITests/Helpers/PlayersFinder.swift index 5a3be7e..7530e58 100644 --- a/FootballGather/UITests/Helpers/PlayersFinder.swift +++ b/FootballGather/UITests/Helpers/PlayersFinder.swift @@ -14,6 +14,7 @@ struct PlayersFinder { private let app: XCUIApplication private let table: XCUIElement + @MainActor init(app: XCUIApplication, table: XCUIElement) { self.app = app self.table = table diff --git a/FootballGather/UITests/Helpers/UITestCase.swift b/FootballGather/UITests/Helpers/UITestCase.swift index 6e9020b..5ee4c33 100644 --- a/FootballGather/UITests/Helpers/UITestCase.swift +++ b/FootballGather/UITests/Helpers/UITestCase.swift @@ -9,26 +9,26 @@ import XCTest import FoundationTools import PlayerDetailsAssets -class UITestCase: XCTestCase { +class UITestCase: XCTestCase, @unchecked Sendable { var app: XCUIApplication! @MainActor lazy var saveButton = app.buttons[.saveButton] - - @MainActor - override func setUpWithError() throws { - try super.setUpWithError() + + override func setUp() async throws { + try await super.setUp() continueAfterFailure = false app = XCUIApplication() - app.launchArguments = ["-uitests"] + Task { @MainActor in + app.launchArguments = ["-uitests"] + } } - @MainActor - override func tearDownWithError() throws { - app.terminate() - try super.tearDownWithError() + override func tearDown() async throws { + await app.terminate() + try await super.tearDown() } @MainActor diff --git a/FootballGather/UITests/UseCases/Add/AddPlayerUITests.swift b/FootballGather/UITests/UseCases/Add/AddPlayerUITests.swift index 6af6724..285386d 100644 --- a/FootballGather/UITests/UseCases/Add/AddPlayerUITests.swift +++ b/FootballGather/UITests/UseCases/Add/AddPlayerUITests.swift @@ -8,20 +8,19 @@ import XCTest import CoreModels -final class AddPlayerUITests: UITestCase { +final class AddPlayerUITests: UITestCase, @unchecked Sendable { private var selectionHandler: PlayerDetailsSelection! // MARK: - Setup - @MainActor - override func setUp() { - super.setUp() - - selectionHandler = PlayerDetailsSelection(app: app) - launchApp() - presentEmptyView() - presentAddView() + override func setUp() async throws { + try await super.setUp() + + selectionHandler = await PlayerDetailsSelection(app: app) + await launchApp() + await presentEmptyView() + await presentAddView() } @MainActor diff --git a/FootballGather/UITests/UseCases/Confirmation/ConfirmPlayersUITests.swift b/FootballGather/UITests/UseCases/Confirmation/ConfirmPlayersUITests.swift index f45d3dd..0ce3b99 100644 --- a/FootballGather/UITests/UseCases/Confirmation/ConfirmPlayersUITests.swift +++ b/FootballGather/UITests/UseCases/Confirmation/ConfirmPlayersUITests.swift @@ -8,24 +8,23 @@ import XCTest import CoreModels -final class ConfirmPlayersUITests: UITestCase { +final class ConfirmPlayersUITests: UITestCase, @unchecked Sendable { var playersFinder: PlayersFinder! private var navigator: AppNavigator! // MARK: - Setup - - @MainActor - override func setUp() { - super.setUp() + + override func setUp() async throws { + try await super.setUp() - playersFinder = PlayersFinder(app: app, table: confirmTable) - navigator = .init(app: app, testCase: self) + playersFinder = await PlayersFinder(app: app, table: confirmTable) + navigator = await .init(app: app, testCase: self) - launchApp(populatingStorage: true) - navigator.presentPlayerListView() - navigator.presentConfirmPlayersView() + await launchApp(populatingStorage: true) + await navigator.presentPlayerListView() + await navigator.presentConfirmPlayersView() } } diff --git a/FootballGather/UITests/UseCases/Details/PlayerDetailsUITests.swift b/FootballGather/UITests/UseCases/Details/PlayerDetailsUITests.swift index 9eef859..afe5298 100644 --- a/FootballGather/UITests/UseCases/Details/PlayerDetailsUITests.swift +++ b/FootballGather/UITests/UseCases/Details/PlayerDetailsUITests.swift @@ -9,14 +9,13 @@ import XCTest import CoreModels import PlayerDetailsAssets -final class PlayerDetailsUITests: UITestCase { +final class PlayerDetailsUITests: UITestCase, @unchecked Sendable { // MARK: - Setup - @MainActor - override func setUp() { - super.setUp() - launchApp(populatingStorage: true) + override func setUp() async throws { + try await super.setUp() + await launchApp(populatingStorage: true) } /// **Scenario 1: Navigating to details screen** diff --git a/FootballGather/UITests/UseCases/Edit/EditPlayerUITests.swift b/FootballGather/UITests/UseCases/Edit/EditPlayerUITests.swift index bdf99b7..4520188 100644 --- a/FootballGather/UITests/UseCases/Edit/EditPlayerUITests.swift +++ b/FootballGather/UITests/UseCases/Edit/EditPlayerUITests.swift @@ -8,7 +8,7 @@ import XCTest import CoreModels -final class EditPlayerUITests: UITestCase { +final class EditPlayerUITests: UITestCase, @unchecked Sendable { var selectionHandler: PlayerDetailsSelection! @@ -21,13 +21,12 @@ final class EditPlayerUITests: UITestCase { // MARK: - Setup - @MainActor - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() - selectionHandler = PlayerDetailsSelection(app: app) - launchApp(populatingStorage: true) - presentPlayerDetails() + selectionHandler = await PlayerDetailsSelection(app: app) + await launchApp(populatingStorage: true) + await presentPlayerDetails() } @MainActor diff --git a/FootballGather/UITests/UseCases/Gather/GatherUITests.swift b/FootballGather/UITests/UseCases/Gather/GatherUITests.swift index 1f8b5c0..6dee257 100644 --- a/FootballGather/UITests/UseCases/Gather/GatherUITests.swift +++ b/FootballGather/UITests/UseCases/Gather/GatherUITests.swift @@ -10,20 +10,19 @@ import CoreModels import GatherAssets import FoundationTools -final class GatherUITests: UITestCase { +final class GatherUITests: UITestCase, @unchecked Sendable { private var navigator: AppNavigator! - @MainActor - override func setUp() { - super.setUp() + override func setUp() async throws { + try await super.setUp() - addUIInterruptionMonitor() + await addUIInterruptionMonitor() - launchApp(populatingStorage: true) + await launchApp(populatingStorage: true) - navigator = .init(app: app, testCase: self) - navigator.presentGatherView() + navigator = await .init(app: app, testCase: self) + await navigator.presentGatherView() } @MainActor diff --git a/FootballGather/UITests/UseCases/History/HistoryViewUITests.swift b/FootballGather/UITests/UseCases/History/HistoryViewUITests.swift index de04da2..bf10d1d 100644 --- a/FootballGather/UITests/UseCases/History/HistoryViewUITests.swift +++ b/FootballGather/UITests/UseCases/History/HistoryViewUITests.swift @@ -8,7 +8,7 @@ import XCTest import HistoryAssets -final class HistoryViewUITests: UITestCase { +final class HistoryViewUITests: UITestCase, @unchecked Sendable { /// **Scenario 1: Navigating to History screen** /// diff --git a/FootballGather/UITests/UseCases/List/PlayerListUITests.swift b/FootballGather/UITests/UseCases/List/PlayerListUITests.swift index 4ac3686..b07be2e 100644 --- a/FootballGather/UITests/UseCases/List/PlayerListUITests.swift +++ b/FootballGather/UITests/UseCases/List/PlayerListUITests.swift @@ -7,7 +7,7 @@ import XCTest -final class PlayerListUITests: UITestCase { +final class PlayerListUITests: UITestCase, @unchecked Sendable { /// **Scenario 1: View list of players** ///