Skip to content

Commit

Permalink
Fix all tests in Xcode 16 beta 5
Browse files Browse the repository at this point in the history
  • Loading branch information
radude89 committed Aug 14, 2024
1 parent ee21860 commit 8c124d5
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import TeamSelectionAssets

// MARK: - ConfirmPlayersViewController

final class ConfirmPlayersViewController: UIViewController {
@MainActor
final class ConfirmPlayersViewController: UIViewController, @unchecked Sendable {

// MARK: - Properties

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -301,6 +303,7 @@ final class ConfirmPlayersViewControllerTests: XCTestCase {
}

private final class MockGatherCoordinator: GatherCoordinatable {
@MainActor
func startGather(from parent: UIViewController, playersTeams: [Team : [Player]], animated: Bool) {
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
54 changes: 26 additions & 28 deletions FootballGather/Snapshots/Snapshots.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions FootballGather/UITests/Helpers/PlayersFinder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions FootballGather/UITests/Helpers/UITestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 8 additions & 9 deletions FootballGather/UITests/UseCases/Add/AddPlayerUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
13 changes: 6 additions & 7 deletions FootballGather/UITests/UseCases/Edit/EditPlayerUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import XCTest
import CoreModels

final class EditPlayerUITests: UITestCase {
final class EditPlayerUITests: UITestCase, @unchecked Sendable {

var selectionHandler: PlayerDetailsSelection!

Expand All @@ -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
Expand Down
15 changes: 7 additions & 8 deletions FootballGather/UITests/UseCases/Gather/GatherUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import XCTest
import HistoryAssets

final class HistoryViewUITests: UITestCase {
final class HistoryViewUITests: UITestCase, @unchecked Sendable {

/// **Scenario 1: Navigating to History screen**
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import XCTest

final class PlayerListUITests: UITestCase {
final class PlayerListUITests: UITestCase, @unchecked Sendable {

/// **Scenario 1: View list of players**
///
Expand Down

0 comments on commit 8c124d5

Please sign in to comment.