Skip to content

Commit f7dca29

Browse files
committed
Try UI tests app launch
1 parent ed37623 commit f7dca29

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

ios-baseUITests/XCUIApplicationExtension.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extension XCUIApplication {
2525
func logOutIfNeeded(in testCase: XCTestCase) {
2626
let logOutButton = buttons["LogoutButton"]
2727
let goToSignInButton = buttons["GoToSignInButton"]
28-
28+
2929
if logOutButton.exists {
3030
logOutButton.forceTap()
3131
testCase.waitFor(element: goToSignInButton, timeOut: 5)
@@ -40,12 +40,12 @@ extension XCUIApplication {
4040
let goToSignInButton = buttons["GoToSignInButton"]
4141
let toolbarDoneButton = buttons["Toolbar Done Button"]
4242

43-
testCase.waitFor(element: goToSignInButton, timeOut: 2)
43+
testCase.waitFor(element: goToSignInButton, timeOut: 5)
4444
goToSignInButton.forceTap()
4545

4646
let signInButton = buttons["SignInButton"]
4747

48-
testCase.waitFor(element: signInButton, timeOut: 2)
48+
testCase.waitFor(element: signInButton, timeOut: 5)
4949

5050
type(text: email, on: "EmailTextField")
5151

@@ -67,7 +67,7 @@ extension XCUIApplication {
6767

6868
let toolbarDoneButton = buttons["Toolbar Done Button"]
6969
let signUpButton = buttons["SignUpButton"]
70-
testCase.waitFor(element: signUpButton, timeOut: 2)
70+
testCase.waitFor(element: signUpButton, timeOut: 5)
7171

7272
type(text: email, on: "EmailTextField")
7373

ios-baseUITests/ios_baseUITests.swift

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@
99
import XCTest
1010

1111
class ios_baseUITests: XCTestCase {
12-
12+
1313
var app: XCUIApplication!
1414

15-
let networkMocker = NetworkMocker()
15+
private var networkMocker: NetworkMocker!
1616

1717
override func setUpWithError() throws {
1818
try super.setUpWithError()
1919
app = XCUIApplication()
2020
app.launchArguments = ["Automation Test"]
21-
21+
app.launch()
22+
23+
networkMocker = NetworkMocker()
2224
try networkMocker.setUp()
2325
networkMocker.stub(with: .logOut, method: .DELETE)
2426
app.logOutIfNeeded(in: self)
@@ -30,8 +32,6 @@ class ios_baseUITests: XCTestCase {
3032
}
3133

3234
func testCreateAccountValidations() {
33-
app.launch()
34-
3535
app.buttons["GoToSignUpButton"].forceTap()
3636

3737
let toolbarDoneButton = app.buttons["Toolbar Done Button"]
@@ -66,8 +66,6 @@ class ios_baseUITests: XCTestCase {
6666
}
6767

6868
func testAccountCreation() {
69-
app.launch()
70-
7169
networkMocker.stub(with: .signUp(success: true), method: .POST)
7270

7371
app.attemptSignUp(
@@ -90,8 +88,6 @@ class ios_baseUITests: XCTestCase {
9088
}
9189

9290
func testSignInSuccess() {
93-
app.launch()
94-
9591
networkMocker.stub(with: .signIn(success: true), method: .POST)
9692

9793
app.attemptSignIn(in: self,
@@ -103,8 +99,6 @@ class ios_baseUITests: XCTestCase {
10399
}
104100

105101
func testSignInFailure() {
106-
app.launch()
107-
108102
networkMocker.stub(with: .signIn(success: false), method: .POST)
109103

110104
app.attemptSignIn(in: self,
@@ -122,8 +116,6 @@ class ios_baseUITests: XCTestCase {
122116
}
123117

124118
func testSignInValidations() {
125-
app.launch()
126-
127119
app.buttons["GoToSignInButton"].forceTap()
128120

129121
let toolbarDoneButton = app.buttons["Toolbar Done Button"]

ios-baseUnitTests/Cases/Services/UserServiceUnitTests.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ import RSSwiftNetworking
1313
class UserServiceUnitTests: XCTestCase {
1414

1515
private var userService: UserServices!
16-
private let networkMocker = NetworkMocker()
16+
private var networkMocker: NetworkMocker!
1717

1818
override func setUpWithError() throws {
1919
try super.setUpWithError()
2020

21+
networkMocker = NetworkMocker()
2122
try networkMocker.setUp()
2223
userService = UserServices()
2324
UserDataManager.deleteUser()
@@ -49,8 +50,10 @@ class UserServiceUnitTests: XCTestCase {
4950
let expectation = expectation(description: "Request should fail")
5051
testUserStorageAfterProfileFetch(success: false) { result in
5152
switch result {
52-
case .success:
53-
XCTFail("Test expected to fail")
53+
case .success(let user):
54+
print("DB* \(user)")
55+
print("DB* \(String(describing: UserDataManager.currentUser))")
56+
XCTFail("GET Profile Request expected to fail")
5457
case .failure(let error):
5558
expectation.fulfill()
5659
XCTAssertNil(UserDataManager.currentUser)

0 commit comments

Comments
 (0)