Skip to content

Commit

Permalink
Add smoke-test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
fcanas committed Jan 1, 2016
1 parent be033a6 commit 95a8d95
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
68 changes: 68 additions & 0 deletions ExemplaryUITests/TestFullSuite.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// TestFullSuite.m
// Formulary
//
// Created by Fabian Canas on 12/30/15.
// Copyright © 2015 Fabian Canas. All rights reserved.
//

#import <XCTest/XCTest.h>

@interface TestFullSuite : XCTestCase

@end

@implementation TestFullSuite

- (void)setUp
{
[super setUp];
self.continueAfterFailure = NO;
[[[XCUIApplication alloc] init] launch];
}

- (void)testExample
{
XCUIApplication *app = [[XCUIApplication alloc] init];
XCUIElementQuery *tablesQuery = app.tables;
[tablesQuery.textFields[@"Name"] tap];
[tablesQuery.textFields[@"Name"] typeText:@"Testy"];
XCTAssertTrue(tablesQuery.textFields[@"Name, Testy"].exists);

[tablesQuery.textFields[@"Email"] tap];

[tablesQuery.textFields[@"Email"] typeText:@"[email protected]"];

XCTAssertTrue(tablesQuery.textFields[@"Email, [email protected]"].exists);

[tablesQuery.textFields[@"Age"] tap];
[tablesQuery.textFields[@"Age"] typeText:@"28"];
XCTAssertTrue(tablesQuery.textFields[@"Age, 28"].exists);

XCUIElement *favoriteNumberTextField = tablesQuery.textFields[@"Favorite Number"];
[favoriteNumberTextField tap];
[favoriteNumberTextField typeText:@"12"];
// Drag to lose focus
[[[tablesQuery childrenMatchingType:XCUIElementTypeCell] elementBoundByIndex:0] pressForDuration:0 thenDragToElement:[[tablesQuery childrenMatchingType:XCUIElementTypeCell] elementBoundByIndex:1]];
XCTAssertTrue(tablesQuery.textFields[@"Favorite Number, 12, Your favorite number must be at least 47"].exists);

[tablesQuery.switches[@"Do you like goats?"] tap];

XCUIElement *otherThoughtsTextField = tablesQuery.textFields[@"Other Thoughts?"];
[otherThoughtsTextField tap];
[otherThoughtsTextField typeText:@"Some thoughts"];

[tablesQuery.staticTexts[@"Pizza"] tap];
[tablesQuery.staticTexts[@"Ice Cream"] tap];
[tablesQuery.staticTexts[@"Ice Cream"] pressForDuration:0 thenDragToElement:tablesQuery.switches[@"Do you like goats?"]];

[[tablesQuery.cells containingType:XCUIElementTypeButton identifier:@"Show Values"].element tap];

XCUIElement *formValuesAlert = app.alerts[@"Form Values"];
XCUIElement *staticTextResult = formValuesAlert.staticTexts[@"{\"likesGoats\":true,\"Food\":[\"Ice Cream\",\"Pizza\"],\"age\":\"28\",\"favoriteNumber\":\"12\",\"email\":\"[email protected]\",\"thoughts\":\"Some thoughts\",\"name\":\"Testy\"}"];
XCTAssertTrue(staticTextResult.exists);

[formValuesAlert.collectionViews.buttons[@"Ok"] tap];
}

@end
5 changes: 5 additions & 0 deletions Formulary.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
E784ECDD1B780F780083D78F /* UIControlEventAcion.swift in Sources */ = {isa = PBXBuildFile; fileRef = E784ECDC1B780F780083D78F /* UIControlEventAcion.swift */; };
E784ECDF1B78E6E70083D78F /* ResponderChain.swift in Sources */ = {isa = PBXBuildFile; fileRef = E784ECDE1B78E6E70083D78F /* ResponderChain.swift */; };
E7E30FC11C307EA400E37C7A /* TestValidations.m in Sources */ = {isa = PBXBuildFile; fileRef = E7E30FC01C307EA400E37C7A /* TestValidations.m */; };
E7E30FC31C34D59F00E37C7A /* TestFullSuite.m in Sources */ = {isa = PBXBuildFile; fileRef = E7E30FC21C34D59F00E37C7A /* TestFullSuite.m */; };
E7F1A95C1A69A30500FD8294 /* FormDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7F1A95B1A69A30500FD8294 /* FormDataSource.swift */; };
E7F1A95E1A69A34700FD8294 /* Form.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7F1A95D1A69A34700FD8294 /* Form.swift */; };
E7F1A9611A69C2CC00FD8294 /* Cell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7F1A9601A69C2CC00FD8294 /* Cell.swift */; };
Expand Down Expand Up @@ -97,6 +98,7 @@
E7E30FB91C306E0000E37C7A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E7E30FBF1C307EA400E37C7A /* ExemplaryUITests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ExemplaryUITests-Bridging-Header.h"; sourceTree = "<group>"; };
E7E30FC01C307EA400E37C7A /* TestValidations.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestValidations.m; sourceTree = "<group>"; };
E7E30FC21C34D59F00E37C7A /* TestFullSuite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestFullSuite.m; sourceTree = "<group>"; };
E7F1A95B1A69A30500FD8294 /* FormDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormDataSource.swift; sourceTree = "<group>"; };
E7F1A95D1A69A34700FD8294 /* Form.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Form.swift; sourceTree = "<group>"; };
E7F1A9601A69C2CC00FD8294 /* Cell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -257,6 +259,7 @@
E7E30FB91C306E0000E37C7A /* Info.plist */,
E7E30FC01C307EA400E37C7A /* TestValidations.m */,
E7E30FBF1C307EA400E37C7A /* ExemplaryUITests-Bridging-Header.h */,
E7E30FC21C34D59F00E37C7A /* TestFullSuite.m */,
);
path = ExemplaryUITests;
sourceTree = "<group>";
Expand Down Expand Up @@ -471,6 +474,7 @@
buildActionMask = 2147483647;
files = (
E7E30FC11C307EA400E37C7A /* TestValidations.m in Sources */,
E7E30FC31C34D59F00E37C7A /* TestFullSuite.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -777,6 +781,7 @@
E7E30FBE1C306E0000E37C7A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down

0 comments on commit 95a8d95

Please sign in to comment.