Skip to content

Commit cf02def

Browse files
authored
Add UI Test suite (#314)
1 parent 3e52295 commit cf02def

File tree

24 files changed

+981
-17
lines changed

24 files changed

+981
-17
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ jobs:
132132
run: fastlane test platform:${{ matrix.platform[0] }} version:${{ matrix.platform[1] }} scheme:Introspect
133133

134134
- if: ${{ join(matrix.platform, ' ') != 'macos 11' }}
135-
name: Run Tests (SwiftUIIntrospect, Debug)
135+
name: Run Tests (SwiftUIIntrospect)
136136
run: fastlane test platform:${{ matrix.platform[0] }} version:${{ matrix.platform[1] }} scheme:SwiftUIIntrospectTests configuration:Debug
137137

138-
- if: ${{ join(matrix.platform, ' ') != 'macos 11' }}
139-
name: Run Tests (SwiftUIIntrospect, Release)
140-
run: fastlane test platform:${{ matrix.platform[0] }} version:${{ matrix.platform[1] }} scheme:SwiftUIIntrospectTests configuration:Release
138+
- if: ${{ matrix.platform[0] == 'ios' && matrix.platform[1] >= '14' && matrix.platform[1] <= '16' }}
139+
name: Run UI Tests (SwiftUIIntrospect)
140+
run: fastlane test platform:${{ matrix.platform[0] }} version:${{ matrix.platform[1] }} scheme:SwiftUIIntrospectUITests configuration:Debug

SwiftUIIntrospect.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tests/Tests.xcodeproj/project.pbxproj

Lines changed: 589 additions & 13 deletions
Large diffs are not rendered by default.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1500"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "D58D833E2A66C5EC00A203BE"
18+
BuildableName = "UITestsHostApp.app"
19+
BlueprintName = "UITestsHostApp"
20+
ReferencedContainer = "container:Tests.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<TestPlans>
31+
<TestPlanReference
32+
reference = "container:UITests/UITests.xctestplan"
33+
default = "YES">
34+
</TestPlanReference>
35+
</TestPlans>
36+
</TestAction>
37+
<LaunchAction
38+
buildConfiguration = "Debug"
39+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
40+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
41+
launchStyle = "0"
42+
useCustomWorkingDirectory = "NO"
43+
ignoresPersistentStateOnLaunch = "NO"
44+
debugDocumentVersioning = "YES"
45+
debugServiceExtension = "internal"
46+
allowLocationSimulation = "YES">
47+
<BuildableProductRunnable
48+
runnableDebuggingMode = "0">
49+
<BuildableReference
50+
BuildableIdentifier = "primary"
51+
BlueprintIdentifier = "D58D833E2A66C5EC00A203BE"
52+
BuildableName = "UITestsHostApp.app"
53+
BlueprintName = "UITestsHostApp"
54+
ReferencedContainer = "container:Tests.xcodeproj">
55+
</BuildableReference>
56+
</BuildableProductRunnable>
57+
</LaunchAction>
58+
<ProfileAction
59+
buildConfiguration = "Release"
60+
shouldUseLaunchSchemeArgsEnv = "YES"
61+
savedToolIdentifier = ""
62+
useCustomWorkingDirectory = "NO"
63+
debugDocumentVersioning = "YES">
64+
<BuildableProductRunnable
65+
runnableDebuggingMode = "0">
66+
<BuildableReference
67+
BuildableIdentifier = "primary"
68+
BlueprintIdentifier = "D58D833E2A66C5EC00A203BE"
69+
BuildableName = "UITestsHostApp.app"
70+
BlueprintName = "UITestsHostApp"
71+
ReferencedContainer = "container:Tests.xcodeproj">
72+
</BuildableReference>
73+
</BuildableProductRunnable>
74+
</ProfileAction>
75+
<AnalyzeAction
76+
buildConfiguration = "Debug">
77+
</AnalyzeAction>
78+
<ArchiveAction
79+
buildConfiguration = "Release"
80+
revealArchiveInOrganizer = "YES">
81+
</ArchiveAction>
82+
</Scheme>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import SnapshotTesting
2+
import XCTest
3+
4+
final class StatusBarStyleUITests: UITestCase {
5+
override var testCase: TestCase {
6+
.statusBarStyle
7+
}
8+
9+
func test() throws {
10+
guard #unavailable(iOS 17) else {
11+
throw XCTSkip("SimulatorStatusMagic stopped working in iOS 17, so we can no longer consistently compare status bar screenshots")
12+
}
13+
14+
app.buttons["Navigate To Detail"].tap()
15+
app.buttons["Navigate To Detail"].tap()
16+
app.buttons["Navigate Back"].tap()
17+
18+
let iOSDevice = UIDevice.current.userInterfaceIdiom == .pad ? "ipad" : "iphone"
19+
let iOSVersion = ProcessInfo().operatingSystemVersion
20+
func screenshotName(_ number: Int) -> String {
21+
"\(iOSDevice)-ios-\(iOSVersion.majorVersion)-screenshot-\(number)"
22+
}
23+
24+
assertSnapshot(
25+
matching: app.windows.firstMatch.screenshot().image,
26+
as: .image(perceptualPrecision: 0.95),
27+
named: screenshotName(1)
28+
)
29+
}
30+
}

Tests/UITests/UITestCase.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import SimulatorStatusMagic
2+
import XCTest
3+
4+
class UITestCase: XCTestCase {
5+
var testCase: TestCase {
6+
preconditionFailure("Please override this property")
7+
}
8+
9+
let app = XCUIApplication()
10+
11+
override func invokeTest() {
12+
SDStatusBarManager.sharedInstance().enableOverrides()
13+
14+
continueAfterFailure = false
15+
16+
app.launchEnvironment["testCase"] = testCase.rawValue
17+
app.launch()
18+
19+
super.invokeTest()
20+
}
21+
}

Tests/UITests/UITests.xctestplan

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"configurations" : [
3+
{
4+
"id" : "DD0EEECD-4762-4A68-91A8-F7B5A2209B45",
5+
"name" : "Test Scheme Action",
6+
"options" : {
7+
8+
}
9+
}
10+
],
11+
"defaultOptions" : {
12+
13+
},
14+
"testTargets" : [
15+
{
16+
"target" : {
17+
"containerPath" : "container:Tests.xcodeproj",
18+
"identifier" : "D58D832A2A66BDD500A203BE",
19+
"name" : "UITests"
20+
}
21+
}
22+
],
23+
"version" : 1
24+
}
62.8 KB
Loading
74.3 KB
Loading
75.6 KB
Loading

0 commit comments

Comments
 (0)