Skip to content
This repository was archived by the owner on Jun 22, 2021. It is now read-only.

Commit c8965c2

Browse files
committed
Add xctest ui tests.
1 parent 1835c06 commit c8965c2

File tree

7 files changed

+283
-145
lines changed

7 files changed

+283
-145
lines changed

Contacts.xcodeproj/project.pbxproj

Lines changed: 107 additions & 103 deletions
Large diffs are not rendered by default.

Contacts/Base.lproj/Main.storyboard

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
154154
<nil key="highlightedColor"/>
155155
</label>
156-
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="xrA-LS-W3q">
156+
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="xrA-LS-W3q">
157157
<rect key="frame" x="118" y="15" width="467" height="30"/>
158158
<animations/>
159159
<fontDescription key="fontDescription" type="system" pointSize="14"/>
@@ -188,7 +188,7 @@
188188
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
189189
<nil key="highlightedColor"/>
190190
</label>
191-
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="uSX-Ot-pHZ">
191+
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="uSX-Ot-pHZ">
192192
<rect key="frame" x="117" y="15" width="468" height="30"/>
193193
<animations/>
194194
<fontDescription key="fontDescription" type="system" pointSize="14"/>

ContactsTests/ContactsTests.m

Lines changed: 0 additions & 40 deletions
This file was deleted.

ContactsUITests/AddContactsTests.m

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//
2+
// AddContactsTests.m
3+
// Contacts
4+
//
5+
// Created by Alex Maimescu on 11/18/15.
6+
// Copyright © 2015 alexmx. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
11+
@interface AddContactsTests : XCTestCase
12+
13+
@end
14+
15+
@implementation AddContactsTests
16+
17+
- (void)setUp
18+
{
19+
[super setUp];
20+
21+
self.continueAfterFailure = NO;
22+
[[[XCUIApplication alloc] init] launch];
23+
}
24+
25+
- (void)tearDown
26+
{
27+
[super tearDown];
28+
}
29+
30+
- (void)testAddContact
31+
{
32+
XCUIApplication *app = [[XCUIApplication alloc] init];
33+
[app.navigationBars[@"Contacts"].buttons[@"Add"] tap];
34+
35+
XCUIElement *comVcContactseditTable = app.tables[@"com.vc.contactsEdit"];
36+
XCUIElement *comTextfieldFirstnameTextField = comVcContactseditTable.textFields[@"com.textfield.firstName"];
37+
[comTextfieldFirstnameTextField tap];
38+
[comTextfieldFirstnameTextField typeText:@"Jon"];
39+
40+
XCUIElement *comTextfieldLastnameTextField = comVcContactseditTable.textFields[@"com.textfield.lastName"];
41+
[comTextfieldLastnameTextField tap];
42+
[comTextfieldLastnameTextField tap];
43+
[comTextfieldLastnameTextField typeText:@"Snow"];
44+
[app.navigationBars[@"Edit Contact Details"].buttons[@"Done"] tap];
45+
46+
XCTAssertNotNil(app.tables[@"com.vc.contactsList"].cells[@"Jon Snow"]);
47+
XCTAssertEqual(app.tables[@"com.vc.contactsList"].cells.count, 1);
48+
}
49+
50+
@end
File renamed without changes.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//
2+
// RemoveContactTests.m
3+
// Contacts
4+
//
5+
// Created by Alex Maimescu on 11/18/15.
6+
// Copyright © 2015 alexmx. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
11+
@interface RemoveContactTests : XCTestCase
12+
13+
@end
14+
15+
@implementation RemoveContactTests
16+
17+
- (void)setUp
18+
{
19+
[super setUp];
20+
21+
self.continueAfterFailure = NO;
22+
[[[XCUIApplication alloc] init] launch];
23+
}
24+
25+
- (void)tearDown
26+
{
27+
[super tearDown];
28+
}
29+
30+
- (void)testRemoveContact
31+
{
32+
XCUIApplication *app = [[XCUIApplication alloc] init];
33+
XCUIElement *contactsNavigationBar = app.navigationBars[@"Contacts"];
34+
[contactsNavigationBar.buttons[@"Add"] tap];
35+
36+
XCUIElement *comVcContactseditTable = app.tables[@"com.vc.contactsEdit"];
37+
XCUIElement *comTextfieldFirstnameTextField = comVcContactseditTable.textFields[@"com.textfield.firstName"];
38+
[comTextfieldFirstnameTextField tap];
39+
[comTextfieldFirstnameTextField typeText:@"Jon"];
40+
41+
XCUIElement *comTextfieldLastnameTextField = comVcContactseditTable.textFields[@"com.textfield.lastName"];
42+
[comTextfieldLastnameTextField tap];
43+
[comTextfieldLastnameTextField tap];
44+
[comTextfieldLastnameTextField typeText:@"Snow"];
45+
[app.navigationBars[@"Edit Contact Details"].buttons[@"Done"] tap];
46+
[contactsNavigationBar.buttons[@"Edit"] tap];
47+
48+
XCUIElement *comVcContactslistTable = app.tables[@"com.vc.contactsList"];
49+
[comVcContactslistTable.buttons[@"Delete Jon Snow"] tap];
50+
[comVcContactslistTable.buttons[@"Delete"] tap];
51+
52+
XCTAssertEqual(app.tables[@"com.vc.contactsList"].cells.count, 0);
53+
}
54+
55+
@end
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
//
2+
// UpdateContactTests.m
3+
// Contacts
4+
//
5+
// Created by Alex Maimescu on 11/18/15.
6+
// Copyright © 2015 alexmx. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
11+
@interface UpdateContactTests : XCTestCase
12+
13+
@end
14+
15+
@implementation UpdateContactTests
16+
17+
- (void)setUp
18+
{
19+
[super setUp];
20+
21+
self.continueAfterFailure = NO;
22+
[[[XCUIApplication alloc] init] launch];
23+
}
24+
25+
- (void)tearDown
26+
{
27+
[super tearDown];
28+
}
29+
30+
- (void)testUpdateContact
31+
{
32+
33+
XCUIApplication *app = [[XCUIApplication alloc] init];
34+
[app.navigationBars[@"Contacts"].buttons[@"Add"] tap];
35+
36+
XCUIElement *comVcContactseditTable2 = app.tables[@"com.vc.contactsEdit"];
37+
XCUIElement *comTextfieldFirstnameTextField = comVcContactseditTable2.textFields[@"com.textfield.firstName"];
38+
[comTextfieldFirstnameTextField tap];
39+
[comTextfieldFirstnameTextField typeText:@"Jon"];
40+
41+
XCUIElement *comTextfieldLastnameTextField = comVcContactseditTable2.textFields[@"com.textfield.lastName"];
42+
[comTextfieldLastnameTextField tap];
43+
[comTextfieldLastnameTextField typeText:@"Snow"];
44+
45+
XCUIElement *doneButton = app.navigationBars[@"Edit Contact Details"].buttons[@"Done"];
46+
[doneButton tap];
47+
48+
XCUIApplication *app2 = app;
49+
[app2.tables[@"com.vc.contactsList"].staticTexts[@"Jon Snow"] tap];
50+
51+
XCUIElement *contactNavigationBar = app.navigationBars[@"Contact"];
52+
[contactNavigationBar.buttons[@"Edit"] tap];
53+
[comTextfieldFirstnameTextField tap];
54+
55+
XCUIElement *comVcContactseditTable = app2.tables[@"com.vc.contactsEdit"];
56+
[comVcContactseditTable.buttons[@"Clear text"] tap];
57+
[comTextfieldFirstnameTextField typeText:@"Robb"];
58+
[comTextfieldLastnameTextField tap];
59+
[comTextfieldLastnameTextField tap];
60+
[comVcContactseditTable.buttons[@"Clear text"] tap];
61+
[comTextfieldLastnameTextField typeText:@"Stark"];
62+
[doneButton tap];
63+
[contactNavigationBar.buttons[@"Contacts"] tap];
64+
65+
XCTAssertNotNil(app.tables[@"com.vc.contactsList"].cells[@"Robb Stark"]);
66+
XCTAssertEqual(app.tables[@"com.vc.contactsList"].cells.count, 1);
67+
}
68+
69+
@end

0 commit comments

Comments
 (0)