Skip to content

Commit

Permalink
add snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
ganezasan committed Oct 29, 2018
1 parent fd596f7 commit da250c7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Game.xcodeproj/project.pbxproj
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
02DE4A9C218705020058CC26 /* SnapshotHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02DE4A9B218705020058CC26 /* SnapshotHelper.swift */; };
49EC454A1BF4D532000A8470 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49EC45491BF4D532000A8470 /* AppDelegate.swift */; };
49EC454C1BF4D532000A8470 /* GameScene.sks in Resources */ = {isa = PBXBuildFile; fileRef = 49EC454B1BF4D532000A8470 /* GameScene.sks */; };
49EC454E1BF4D532000A8470 /* GameScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49EC454D1BF4D532000A8470 /* GameScene.swift */; };
Expand Down Expand Up @@ -36,6 +37,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
02DE4A9B218705020058CC26 /* SnapshotHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SnapshotHelper.swift; sourceTree = "<group>"; };
49EC45461BF4D532000A8470 /* Game.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Game.app; sourceTree = BUILT_PRODUCTS_DIR; };
49EC45491BF4D532000A8470 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
49EC454B1BF4D532000A8470 /* GameScene.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = GameScene.sks; sourceTree = "<group>"; };
Expand Down Expand Up @@ -125,6 +127,7 @@
49EC456C1BF4D533000A8470 /* GameUITests */ = {
isa = PBXGroup;
children = (
02DE4A9B218705020058CC26 /* SnapshotHelper.swift */,
49EC456D1BF4D533000A8470 /* GameUITests.swift */,
49EC456F1BF4D533000A8470 /* Info.plist */,
);
Expand Down Expand Up @@ -291,6 +294,7 @@
buildActionMask = 2147483647;
files = (
49EC456E1BF4D533000A8470 /* GameUITests.swift in Sources */,
02DE4A9C218705020058CC26 /* SnapshotHelper.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 2 additions & 0 deletions Game/GameScene.swift
Expand Up @@ -15,6 +15,8 @@ class GameScene: SKScene {
myLabel.text = "Hello, World!";
myLabel.fontSize = 45;
myLabel.position = CGPoint(x:self.frame.midX, y:self.frame.midY);
myLabel.isAccessibilityElement = true
myLabel.accessibilityLabel = "myLabel"

self.addChild(myLabel)
}
Expand Down
12 changes: 11 additions & 1 deletion GameUITests/GameUITests.swift
Expand Up @@ -18,7 +18,9 @@ class GameUITests: XCTestCase {
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
XCUIApplication().launch()
let app = XCUIApplication()
setupSnapshot(app)
app.launch()

// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
Expand All @@ -31,6 +33,14 @@ class GameUITests: XCTestCase {
func testExample() {
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
snapshot("0_Launch")
let app = XCUIApplication()

// Check the string displayed on the label is existing
XCTAssertTrue(app.otherElements["myLabel"].exists)

app.tap()
snapshot("1_Tap")
}

}
1 change: 1 addition & 0 deletions fastlane/Fastfile
Expand Up @@ -8,6 +8,7 @@ platform :ios do
desc "Runs all the tests"
lane :test do
scan
snapshot
end

desc "Ad-hoc build"
Expand Down

0 comments on commit da250c7

Please sign in to comment.