Skip to content

Commit

Permalink
Merge pull request #374 from lou0124/UITest
Browse files Browse the repository at this point in the history
[Test] UITest 작성
  • Loading branch information
lou0124 authored Dec 1, 2021
2 parents 6d6b427 + 2d47397 commit 86dc802
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 3 deletions.
129 changes: 128 additions & 1 deletion SanTa/SanTa.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
98BCF4F52737A3480073E6FB /* SettingsRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BCF4F42737A3480073E6FB /* SettingsRepository.swift */; };
98BCF4F72737A66E0073E6FB /* SettingsUsecase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BCF4F62737A66E0073E6FB /* SettingsUsecase.swift */; };
98BCF4F92737A7120073E6FB /* SettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BCF4F82737A7120073E6FB /* SettingsViewModel.swift */; };
98C954A52757532B0058DD22 /* SanTaUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C954A42757532B0058DD22 /* SanTaUITests.swift */; };
98C954A72757532B0058DD22 /* SanTaUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C954A62757532B0058DD22 /* SanTaUITestsLaunchTests.swift */; };
DA4736D22755E39500841326 /* Location.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA4736D12755E39500841326 /* Location.swift */; };
DA4736E6275610EE00841326 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9826F3DE273904010064FA85 /* Settings.swift */; };
DA4736E7275610F600841326 /* Record.swift in Sources */ = {isa = PBXBuildFile; fileRef = 984DDEC027325D67003BE56B /* Record.swift */; };
Expand Down Expand Up @@ -191,6 +193,13 @@
remoteGlobalIDString = 5485127D272A6AD500407F28;
remoteInfo = SanTa;
};
98C954A82757532B0058DD22 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 54851276272A6AD500407F28 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 5485127D272A6AD500407F28;
remoteInfo = SanTa;
};
DA4736F427561C6200841326 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 54851276272A6AD500407F28 /* Project object */;
Expand Down Expand Up @@ -284,6 +293,9 @@
98BCF4F42737A3480073E6FB /* SettingsRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsRepository.swift; sourceTree = "<group>"; };
98BCF4F62737A66E0073E6FB /* SettingsUsecase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsUsecase.swift; sourceTree = "<group>"; };
98BCF4F82737A7120073E6FB /* SettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewModel.swift; sourceTree = "<group>"; };
98C954A22757532B0058DD22 /* SanTaUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SanTaUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
98C954A42757532B0058DD22 /* SanTaUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SanTaUITests.swift; sourceTree = "<group>"; };
98C954A62757532B0058DD22 /* SanTaUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SanTaUITestsLaunchTests.swift; sourceTree = "<group>"; };
DA4736D12755E39500841326 /* Location.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Location.swift; sourceTree = "<group>"; };
DA4736F027561C6200841326 /* MountainListSceneTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MountainListSceneTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
DA4736F227561C6200841326 /* MountainListSceneTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MountainListSceneTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -354,6 +366,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
98C9549F2757532B0058DD22 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
DA4736ED27561C6200841326 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -558,6 +577,7 @@
5423CD642755FA4A00BAB338 /* MapSceneTests */,
5423CD802755FCEF00BAB338 /* MountainAddingSceneTests */,
4953CB802757092D00A0106F /* ResultDetailAltitudeTest */,
98C954A32757532B0058DD22 /* SanTaUITests */,
5485127F272A6AD500407F28 /* Products */,
);
sourceTree = "<group>";
Expand All @@ -573,6 +593,7 @@
5423CD632755FA4A00BAB338 /* MapSceneTests.xctest */,
5423CD7F2755FCEF00BAB338 /* MountainAddingSceneTests.xctest */,
4953CB7F2757092D00A0106F /* ResultDetailAltitudeTest.xctest */,
98C954A22757532B0058DD22 /* SanTaUITests.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -619,6 +640,15 @@
path = ResultSceneTests;
sourceTree = "<group>";
};
98C954A32757532B0058DD22 /* SanTaUITests */ = {
isa = PBXGroup;
children = (
98C954A42757532B0058DD22 /* SanTaUITests.swift */,
98C954A62757532B0058DD22 /* SanTaUITestsLaunchTests.swift */,
);
path = SanTaUITests;
sourceTree = "<group>";
};
DA4736D32755E46800841326 /* Utility */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -811,6 +841,24 @@
productReference = 98BAABB1275479B0004505BB /* ResultSceneTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
98C954A12757532B0058DD22 /* SanTaUITests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 98C954AC2757532B0058DD22 /* Build configuration list for PBXNativeTarget "SanTaUITests" */;
buildPhases = (
98C9549E2757532B0058DD22 /* Sources */,
98C9549F2757532B0058DD22 /* Frameworks */,
98C954A02757532B0058DD22 /* Resources */,
);
buildRules = (
);
dependencies = (
98C954A92757532B0058DD22 /* PBXTargetDependency */,
);
name = SanTaUITests;
productName = SanTaUITests;
productReference = 98C954A22757532B0058DD22 /* SanTaUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
DA4736EF27561C6200841326 /* MountainListSceneTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = DA4736F627561C6200841326 /* Build configuration list for PBXNativeTarget "MountainListSceneTests" */;
Expand Down Expand Up @@ -853,7 +901,7 @@
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1310;
LastSwiftUpdateCheck = 1300;
LastUpgradeCheck = 1300;
TargetAttributes = {
4953CB7E2757092D00A0106F = {
Expand All @@ -879,6 +927,10 @@
CreatedOnToolsVersion = 13.0;
TestTargetID = 5485127D272A6AD500407F28;
};
98C954A12757532B0058DD22 = {
CreatedOnToolsVersion = 13.0;
TestTargetID = 5485127D272A6AD500407F28;
};
DA4736EF27561C6200841326 = {
CreatedOnToolsVersion = 13.0;
TestTargetID = 5485127D272A6AD500407F28;
Expand Down Expand Up @@ -909,6 +961,7 @@
5423CD622755FA4A00BAB338 /* MapSceneTests */,
5423CD7E2755FCEF00BAB338 /* MountainAddingSceneTests */,
4953CB7E2757092D00A0106F /* ResultDetailAltitudeTest */,
98C954A12757532B0058DD22 /* SanTaUITests */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -959,6 +1012,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
98C954A02757532B0058DD22 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
DA4736EE27561C6200841326 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -1147,6 +1207,15 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
98C9549E2757532B0058DD22 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
98C954A72757532B0058DD22 /* SanTaUITestsLaunchTests.swift in Sources */,
98C954A52757532B0058DD22 /* SanTaUITests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
DA4736EC27561C6200841326 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -1203,6 +1272,11 @@
target = 5485127D272A6AD500407F28 /* SanTa */;
targetProxy = 98BAABB5275479B0004505BB /* PBXContainerItemProxy */;
};
98C954A92757532B0058DD22 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 5485127D272A6AD500407F28 /* SanTa */;
targetProxy = 98C954A82757532B0058DD22 /* PBXContainerItemProxy */;
};
DA4736F527561C6200841326 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 5485127D272A6AD500407F28 /* SanTa */;
Expand Down Expand Up @@ -1630,6 +1704,50 @@
};
name = Release;
};
98C954AA2757532B0058DD22 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = B3PWYBKFUK;
GENERATE_INFOPLIST_FILE = YES;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.ohchangmin.SanTaUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = SanTa;
};
name = Debug;
};
98C954AB2757532B0058DD22 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = B3PWYBKFUK;
GENERATE_INFOPLIST_FILE = YES;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.ohchangmin.SanTaUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = SanTa;
};
name = Release;
};
DA4736F727561C6200841326 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
Expand Down Expand Up @@ -1784,6 +1902,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
98C954AC2757532B0058DD22 /* Build configuration list for PBXNativeTarget "SanTaUITests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
98C954AA2757532B0058DD22 /* Debug */,
98C954AB2757532B0058DD22 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
DA4736F627561C6200841326 /* Build configuration list for PBXNativeTarget "MountainListSceneTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
Expand Down
10 changes: 10 additions & 0 deletions SanTa/SanTa.xcodeproj/xcshareddata/xcschemes/SanTa.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@
ReferencedContainer = "container:SanTa.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "98C954A12757532B0058DD22"
BuildableName = "SanTaUITests.xctest"
BlueprintName = "SanTaUITests"
ReferencedContainer = "container:SanTa.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
3 changes: 2 additions & 1 deletion SanTa/SanTa/Scenes/ResultScene/RecordsViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ final class RecordsViewCell: UICollectionViewCell {

extension RecordsViewCell {

func configureVoiceOverAccessibility() {
func configureVoiceOverAccessibility(indexPath: IndexPath) {
guard let date = self.date.text else { return }
guard var title = self.title.text else { return }
guard let distance = self.distance.text else { return }
Expand All @@ -131,5 +131,6 @@ extension RecordsViewCell {
self.accessibilityLabel = "\(date) 등산기록 정보, 제목: \(title), 거리: \(distance)km, 시간: \(time), 고도차: \(altitude), 걸음: \(steps)"
self.accessibilityTraits = .none
self.accessibilityHint = "등산기록 상세화면으로 넘어가려면 이중 탭 하십시오"
self.accessibilityIdentifier = "RecordsViewCell \(indexPath.section) \(indexPath.item)"
}
}
2 changes: 1 addition & 1 deletion SanTa/SanTa/Scenes/ResultScene/ResultViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ extension ResultViewController: UICollectionViewDataSource {
cell.layer.shadowOpacity = 0.8
cell.layer.shadowOffset = CGSize(width: 0, height: 0.5)
cell.configure(date: cellInfo.date, title: cellInfo.title, distance: cellInfo.distance, time: cellInfo.time, altitude: cellInfo.altitudeDifference, steps: cellInfo.steps)
cell.configureVoiceOverAccessibility()
cell.configureVoiceOverAccessibility(indexPath: indexPath)
return cell
}
}
Expand Down
63 changes: 63 additions & 0 deletions SanTa/SanTaUITests/SanTaUITests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// SanTaUITests.swift
// SanTaUITests
//
// Created by CHANGMIN OH on 2021/12/01.
//

import XCTest

class SanTaUITests: XCTestCase {

var app: XCUIApplication!
override func setUp() {
super.setUp()
continueAfterFailure = false
app = XCUIApplication()
app.launch()
}

override func tearDown() {
app = nil
super.tearDown()
}

func test_측정시작후_측정종료() {
app/*@START_MENU_TOKEN@*/.staticTexts["시작"]/*[[".buttons.matching(identifier: \"시작\").staticTexts[\"시작\"]",".staticTexts[\"시작\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
app.buttons["종료"].tap()
app.alerts["기록 종료"].scrollViews.otherElements.buttons["종료"].tap()
app/*@START_MENU_TOKEN@*/.staticTexts["입력 안함"]/*[[".buttons[\"입력 안함\"].staticTexts[\"입력 안함\"]",".staticTexts[\"입력 안함\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
}


func test_산_검색후_산_상세화면_확인_후_뒤로가기() {
app.tabBars["Tab Bar"].buttons["목록"].tap()
app.navigationBars["산 목록"].searchFields["검색"].tap()
if !app/*@START_MENU_TOKEN@*/.keys[""]/*[[".keyboards.keys[\"ㄱ\"]",".keys[\"ㄱ\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.isHittable {
app.buttons["Next keyboard"].tap()
}

app/*@START_MENU_TOKEN@*/.keys[""]/*[[".keyboards.keys[\"ㄱ\"]",".keys[\"ㄱ\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
app/*@START_MENU_TOKEN@*/.keys[""]/*[[".keyboards.keys[\"ㅏ\"]",".keys[\"ㅏ\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
app/*@START_MENU_TOKEN@*/.keys[""]/*[[".keyboards.keys[\"ㄹ\"]",".keys[\"ㄹ\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
app/*@START_MENU_TOKEN@*/.keys[""]/*[[".keyboards.keys[\"ㄱ\"]",".keys[\"ㄱ\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
app/*@START_MENU_TOKEN@*/.keys[""]/*[[".keyboards.keys[\"ㅣ\"]",".keys[\"ㅣ\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
app/*@START_MENU_TOKEN@*/.keys[""]/*[[".keyboards.keys[\"ㅅ\"]",".keys[\"ㅅ\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
app.keys[""].tap()
app/*@START_MENU_TOKEN@*/.keys[""]/*[[".keyboards.keys[\"ㄴ\"]",".keys[\"ㄴ\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
app/*@START_MENU_TOKEN@*/.buttons["Search"]/*[[".keyboards",".buttons[\"검색\"]",".buttons[\"Search\"]"],[[[-1,2],[-1,1],[-1,0,1]],[[-1,2],[-1,1]]],[0]]@END_MENU_TOKEN@*/.tap()
XCTAssert(app.collectionViews/*@START_MENU_TOKEN@*/.cells["갈기산 685 m 경기도 양평군, 강원도 홍천군 Cell"]/*[[".cells[\"갈기산 685 m 경기도 양평군, 강원도 홍천군\"]",".cells[\"갈기산 685 m 경기도 양평군, 강원도 홍천군 Cell\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.waitForExistence(timeout: 2))
app.collectionViews/*@START_MENU_TOKEN@*/.cells["갈기산 685 m 경기도 양평군, 강원도 홍천군 Cell"]/*[[".cells[\"갈기산 685 m 경기도 양평군, 강원도 홍천군\"]",".cells[\"갈기산 685 m 경기도 양평군, 강원도 홍천군 Cell\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
app.buttons["닫기"].tap()
}

func test_기록화면의_첫_번째_정보_클릭_후_상세_기록_정보_확인() {
app.tabBars["Tab Bar"].buttons["기록"].tap()
guard app.collectionViews/*@START_MENU_TOKEN@*/.cells["RecordsViewCell 1 0"]/*[[".cells[\"오늘(수) 오후 4시 13분 등산기록 정보, 제목: 없음, 거리: 0.00km, 시간: 00:00, 고도차: -, 걸음: 0\"]",".cells[\"RecordsViewCell 1 0\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.isHittable else { return }
app.collectionViews/*@START_MENU_TOKEN@*/.cells["RecordsViewCell 1 0"]/*[[".cells[\"오늘(수) 오후 4시 13분 등산기록 정보, 제목: 없음, 거리: 0.00km, 시간: 00:00, 고도차: -, 걸음: 0\"]",".cells[\"RecordsViewCell 1 0\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
app.otherElements["기록 정보 거리: 0km, 시간: 00:00, 걸음: 0, 최고고도: -, 최저고도: -, 평균속도: -"].swipeUp()
app.windows.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.swipeDown()
app.buttons["뒤로가기"].tap()
}

}
32 changes: 32 additions & 0 deletions SanTa/SanTaUITests/SanTaUITestsLaunchTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// SanTaUITestsLaunchTests.swift
// SanTaUITests
//
// Created by CHANGMIN OH on 2021/12/01.
//

import XCTest

class SanTaUITestsLaunchTests: XCTestCase {

override class var runsForEachTargetApplicationUIConfiguration: Bool {
true
}

override func setUpWithError() throws {
continueAfterFailure = false
}

func testLaunch() throws {
let app = XCUIApplication()
app.launch()

// Insert steps here to perform after app launch but before taking a screenshot,
// such as logging into a test account or navigating somewhere in the app

let attachment = XCTAttachment(screenshot: app.screenshot())
attachment.name = "Launch Screen"
attachment.lifetime = .keepAlways
add(attachment)
}
}

0 comments on commit 86dc802

Please sign in to comment.