From 1142fdcf26dd0fd206130aba3dbee2988051264b Mon Sep 17 00:00:00 2001 From: Chris Ballinger Date: Tue, 11 Jun 2019 15:01:43 -0700 Subject: [PATCH 1/2] Possibly fix failing OHTTPStub tests --- .../app/PRODUCTNAMETests/OAuth/APIClientTests.swift | 11 +++++------ .../app/PRODUCTNAMETests/OAuth/OAuthTests.swift | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/PRODUCTNAME/app/PRODUCTNAMETests/OAuth/APIClientTests.swift b/PRODUCTNAME/app/PRODUCTNAMETests/OAuth/APIClientTests.swift index 64bf969..fad16fb 100644 --- a/PRODUCTNAME/app/PRODUCTNAMETests/OAuth/APIClientTests.swift +++ b/PRODUCTNAME/app/PRODUCTNAMETests/OAuth/APIClientTests.swift @@ -11,14 +11,13 @@ import XCTest @testable import Services class APIClientTests: XCTestCase { - let client: APIClient = { + var client: APIClient! + + override func setUp() { + super.setUp() let configuration = URLSessionConfiguration.default OHHTTPStubs.setEnabled(true, for: configuration) - let client = APIClient(baseURL: TestClient.baseURL, configuration: configuration) - return client - }() - override class func setUp() { - super.setUp() + client = APIClient(baseURL: TestClient.baseURL, configuration: configuration) } override func tearDown() { diff --git a/PRODUCTNAME/app/PRODUCTNAMETests/OAuth/OAuthTests.swift b/PRODUCTNAME/app/PRODUCTNAMETests/OAuth/OAuthTests.swift index 2d26b5f..473f6c8 100644 --- a/PRODUCTNAME/app/PRODUCTNAMETests/OAuth/OAuthTests.swift +++ b/PRODUCTNAME/app/PRODUCTNAMETests/OAuth/OAuthTests.swift @@ -11,7 +11,7 @@ import XCTest @testable import Services class OAuthTests: XCTestCase { - override class func setUp() { + override func setUp() { super.setUp() OHHTTPStubs.setEnabled(true) } From eafd647dee059e94f53d806d2439337e7fd43d45 Mon Sep 17 00:00:00 2001 From: Chris Ballinger Date: Tue, 11 Jun 2019 15:07:28 -0700 Subject: [PATCH 2/2] Attempt to fix issue with randomly failing OHHTTPStubs --- .../OAuth/APIClientTests.swift | 11 +++++------ .../OAuth/OAuthTests.swift | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/{{ cookiecutter.project_name | replace(' ', '') }}/app/{{ cookiecutter.project_name | replace(' ', '') }}Tests/OAuth/APIClientTests.swift b/{{ cookiecutter.project_name | replace(' ', '') }}/app/{{ cookiecutter.project_name | replace(' ', '') }}Tests/OAuth/APIClientTests.swift index e955b5d..325a905 100644 --- a/{{ cookiecutter.project_name | replace(' ', '') }}/app/{{ cookiecutter.project_name | replace(' ', '') }}Tests/OAuth/APIClientTests.swift +++ b/{{ cookiecutter.project_name | replace(' ', '') }}/app/{{ cookiecutter.project_name | replace(' ', '') }}Tests/OAuth/APIClientTests.swift @@ -11,14 +11,13 @@ import XCTest @testable import Services class APIClientTests: XCTestCase { - let client: APIClient = { + var client: APIClient! + + override func setUp() { + super.setUp() let configuration = URLSessionConfiguration.default OHHTTPStubs.setEnabled(true, for: configuration) - let client = APIClient(baseURL: TestClient.baseURL, configuration: configuration) - return client - }() - override class func setUp() { - super.setUp() + client = APIClient(baseURL: TestClient.baseURL, configuration: configuration) } override func tearDown() { diff --git a/{{ cookiecutter.project_name | replace(' ', '') }}/app/{{ cookiecutter.project_name | replace(' ', '') }}Tests/OAuth/OAuthTests.swift b/{{ cookiecutter.project_name | replace(' ', '') }}/app/{{ cookiecutter.project_name | replace(' ', '') }}Tests/OAuth/OAuthTests.swift index ddf835f..e36944b 100644 --- a/{{ cookiecutter.project_name | replace(' ', '') }}/app/{{ cookiecutter.project_name | replace(' ', '') }}Tests/OAuth/OAuthTests.swift +++ b/{{ cookiecutter.project_name | replace(' ', '') }}/app/{{ cookiecutter.project_name | replace(' ', '') }}Tests/OAuth/OAuthTests.swift @@ -11,7 +11,7 @@ import XCTest @testable import Services class OAuthTests: XCTestCase { - override class func setUp() { + override func setUp() { super.setUp() OHHTTPStubs.setEnabled(true) }