Skip to content

Commit

Permalink
Merge pull request #161 from net-a-porter-mobile/travis
Browse files Browse the repository at this point in the history
Add latest xcode and ios tests to travis
  • Loading branch information
deanWombourne authored Mar 30, 2020
2 parents 2150f13 + 17f2498 commit 5c331f3
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 43 deletions.
14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@ before_install:

matrix:
include:
- name: "Xcode 10.2 iOS 12.2"
- name: "Xcode 10.2 iOS 12.2 iPhone 6"
osx_image: xcode10.2
env: DESTINATION='platform=iOS Simulator,name=iPhone 6,OS=12.2' UI=true
- name: "Xcode 10.2 iOS 11.3"
- name: "Xcode 10.2 iOS 11.3 iPhone 6"
osx_image: xcode10.2
env: DESTINATION='platform=iOS Simulator,name=iPhone 6,OS=11.3' UI=true
- name: "Xcode 10.2 iOS 10.3.1"
- name: "Xcode 10.2 iOS 10.3.1 iPhone 6"
osx_image: xcode10.2
env: DESTINATION='platform=iOS Simulator,name=iPhone 6,OS=10.3.1' UI=true
- name: "Xcode 11.3.1 iOS 12.4 iPhone 6"
osx_image: xcode11.3
env: DESTINATION='platform=iOS Simulator,name=iPhone 6,OS=12.4' UI=true
- name: "Xcode 11.3.1 iOS 13.3 iPhone 8"
osx_image: xcode11.3
env: DESTINATION='platform=iOS Simulator,name=iPhone 8,OS=13.3' UI=true

script:
- set -o pipefail
- travis/validate_carthage.sh
- xcodebuild -destination "$DESTINATION" -workspace Example/XCTest-Gherkin.xcworkspace -scheme XCTest-Gherkin-Example -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO test | xcpretty -f `xcpretty-gherkin-formatter/bin/xcpretty-gherkin-formatter`
- if [ $UI ]; then xcodebuild -destination "$DESTINATION" -workspace Example/XCTest-Gherkin.xcworkspace -scheme XCTest-Gherkin-Example-UI -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO test | xcpretty -f `xcpretty-gherkin-formatter/bin/xcpretty-gherkin-formatter`; fi
- bundle exec pod lib lint --allow-warnings
- bundle exec pod lib lint
4 changes: 2 additions & 2 deletions Example/Tests/Features/ExampleFeatures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ final class ExampleFeatures: XCTestCase {
}

func testMatchingStringLiterals() {
/// Test that calling Given when defining the step using `step(exactly:...` will work, and won't be horribly confused by regular expression characters
/// in the step
// Test that calling Given when defining the step using `step(exactly:...` will work, and won't be horribly confused by regular expression characters
// in the step
Given(MatchStringLiteralStepDefiner.literal)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
Expand All @@ -55,6 +55,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
BuildableName = "XCTest-Gherkin_Example.app"
BlueprintName = "XCTest-Gherkin_Example"
ReferencedContainer = "container:XCTest-Gherkin.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -77,17 +86,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
BuildableName = "XCTest-Gherkin_Example.app"
BlueprintName = "XCTest-Gherkin_Example"
ReferencedContainer = "container:XCTest-Gherkin.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -109,8 +107,6 @@
ReferencedContainer = "container:XCTest-Gherkin.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
15 changes: 7 additions & 8 deletions Example/XCTest-Gherkin/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -22,7 +20,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="exv-kf-IFk">
<rect key="frame" x="157.5" y="50" width="60" height="30"/>
<rect key="frame" x="157.5" y="30" width="60" height="30"/>
<accessibility key="accessibilityConfiguration" identifier="PushMe"/>
<state key="normal" title="Push Me"/>
<connections>
Expand All @@ -39,6 +37,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="111" y="32"/>
</scene>
<!--View Controller-->
<scene sceneID="fo4-fC-YEP">
Expand All @@ -49,11 +48,11 @@
<viewControllerLayoutGuide type="bottom" id="khz-9q-ibU"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="CSs-qC-XrM">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="647"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="nBS-lT-Gtc">
<rect key="frame" x="155.5" y="50" width="64" height="30"/>
<rect key="frame" x="155.5" y="30" width="64" height="30"/>
<accessibility key="accessibilityConfiguration" identifier="CloseMe"/>
<state key="normal" title="Close Me"/>
<connections>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ final class UIStepDefiner: StepDefiner {

let identifier = matches.first!

XCUIApplication().buttons[identifier].tap()
XCUIApplication().buttons[identifier].firstMatch.tap()
}

}

}

final class InitialScreenStepDefiner: StepDefiner {
Expand All @@ -38,25 +36,23 @@ final class InitialScreenStepDefiner: StepDefiner {
step("I press Push Me button") {
InitialScreenPageObject().pressPushMe()
}

}

}

final class InitialScreenPageObject: PageObject {

let app = XCUIApplication()
private let app = XCUIApplication()

class override var name: String {
return "Initial Screen"
}

override func isPresented() -> Bool {
return tryWaitFor(element: app.buttons["PushMe"], withState: "exists == true")
return tryWaitFor(element: app.buttons["PushMe"].firstMatch, withState: .exists)
}

func pressPushMe() {
app.buttons["PushMe"].tap()
app.buttons["PushMe"].firstMatch.tap()
}
}

Expand All @@ -67,21 +63,19 @@ final class ModalScreenStepDefiner: StepDefiner {
step("I press Close Me button") {
ModalScreen().pressCloseMe()
}

}

}

final class ModalScreen: PageObject {

let app = XCUIApplication()
private let app = XCUIApplication()

override func isPresented() -> Bool {
return tryWaitFor(element: app.buttons["CloseMe"], withState: "exists == true")
return tryWaitFor(element: app.buttons["CloseMe"].firstMatch, withState: .exists)
}

func pressCloseMe() {
app.buttons["CloseMe"].tap()
app.buttons["CloseMe"].firstMatch.tap()
}
}

Expand All @@ -92,7 +86,12 @@ extension PageObject {
guard predicate.evaluate(with: element) == false else { return true }

let expectation = XCTNSPredicateExpectation(predicate: predicate, object: element)
let result = XCTWaiter().wait(for: [expectation], timeout: timeout) == XCTWaiter.Result.completed
let result = XCTWaiter().wait(for: [expectation], timeout: timeout) == .completed
return result
}
}

extension String {

fileprivate static let exists = "exists == true"
}
3 changes: 2 additions & 1 deletion Pod/Core/PageObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import XCTest
open class PageObject: NSObject {
required public override init() {
super.init()
XCTAssertTrue(isPresented(), "\(type(of: self).name) is not presented")
let presented = isPresented()
XCTAssertTrue(presented, "\(type(of: self).name) is not presented")
}

/// Name of the screen (or its part) that this page object represent.
Expand Down

0 comments on commit 5c331f3

Please sign in to comment.