diff --git a/ExemplaryUITests/TestFullSuite.m b/ExemplaryUITests/TestFullSuite.m new file mode 100644 index 0000000..a240176 --- /dev/null +++ b/ExemplaryUITests/TestFullSuite.m @@ -0,0 +1,68 @@ +// +// TestFullSuite.m +// Formulary +// +// Created by Fabian Canas on 12/30/15. +// Copyright © 2015 Fabian Canas. All rights reserved. +// + +#import + +@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:@"Test@example.com"]; + + XCTAssertTrue(tablesQuery.textFields[@"Email, Test@example.com"].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\":\"Test@example.com\",\"thoughts\":\"Some thoughts\",\"name\":\"Testy\"}"]; + XCTAssertTrue(staticTextResult.exists); + + [formValuesAlert.collectionViews.buttons[@"Ok"] tap]; +} + +@end diff --git a/Formulary.xcodeproj/project.pbxproj b/Formulary.xcodeproj/project.pbxproj index e1cb6e1..58c45bd 100644 --- a/Formulary.xcodeproj/project.pbxproj +++ b/Formulary.xcodeproj/project.pbxproj @@ -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 */; }; @@ -97,6 +98,7 @@ E7E30FB91C306E0000E37C7A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; E7E30FBF1C307EA400E37C7A /* ExemplaryUITests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ExemplaryUITests-Bridging-Header.h"; sourceTree = ""; }; E7E30FC01C307EA400E37C7A /* TestValidations.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestValidations.m; sourceTree = ""; }; + E7E30FC21C34D59F00E37C7A /* TestFullSuite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestFullSuite.m; sourceTree = ""; }; E7F1A95B1A69A30500FD8294 /* FormDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormDataSource.swift; sourceTree = ""; }; E7F1A95D1A69A34700FD8294 /* Form.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Form.swift; sourceTree = ""; }; E7F1A9601A69C2CC00FD8294 /* Cell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cell.swift; sourceTree = ""; }; @@ -257,6 +259,7 @@ E7E30FB91C306E0000E37C7A /* Info.plist */, E7E30FC01C307EA400E37C7A /* TestValidations.m */, E7E30FBF1C307EA400E37C7A /* ExemplaryUITests-Bridging-Header.h */, + E7E30FC21C34D59F00E37C7A /* TestFullSuite.m */, ); path = ExemplaryUITests; sourceTree = ""; @@ -471,6 +474,7 @@ buildActionMask = 2147483647; files = ( E7E30FC11C307EA400E37C7A /* TestValidations.m in Sources */, + E7E30FC31C34D59F00E37C7A /* TestFullSuite.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -777,6 +781,7 @@ E7E30FBE1C306E0000E37C7A /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ };