-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Add first UI test #151
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,19 @@ jobs: | |
CLIENT_TOKEN: ${{ secrets.CONFIDENCE_CLIENT_TOKEN }} | ||
run: scripts/run_tests.sh $CLIENT_TOKEN | ||
|
||
UITests: | ||
runs-on: macOS-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: webfactory/ssh-agent | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SDK_REPO_PRIVATE_KEY }} | ||
- name: Build and UITest | ||
env: | ||
CLIENT_TOKEN: ${{ secrets.CONFIDENCE_CLIENT_TOKEN }} | ||
run: ConfidenceDemoApp/scripts/run_tests.sh $CLIENT_TOKEN | ||
|
||
SwiftLint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.DS_Store | ||
/.build | ||
ConfidenceDemoApp/build/XCBuildData/** | ||
/Packages | ||
/**/*.xcodeproj | ||
xcuserdata/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
371 changes: 128 additions & 243 deletions
371
ConfidenceDemoApp/ConfidenceDemoApp.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
ConfidenceDemoApp/ConfidenceDemoAppUITests/ConfidenceDemoAppUITests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import XCTest | ||
|
||
@testable import ConfidenceDemoApp | ||
|
||
final class ConfidenceDemoAppUITests: XCTestCase { | ||
override func setUpWithError() throws { | ||
try super.setUpWithError() | ||
continueAfterFailure = false | ||
|
||
let app = XCUIApplication() | ||
app.launchEnvironment = ["CLIENT_SECRET": ProcessInfo.processInfo.environment["CLIENT_SECRET"] ?? ""] | ||
app.launch() | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
try super.tearDownWithError() | ||
} | ||
|
||
func testGetFlagValue() { | ||
let app = XCUIApplication() | ||
let button = app.buttons["flag_button"] | ||
button.tap() | ||
let flag = app.staticTexts["flag_text"] | ||
XCTAssertEqual(flag.label, "Yellow") | ||
} | ||
|
||
func testLaunchPerformance() throws { | ||
if #available(macOS 10.15, iOS 17.0, tvOS 13.0, watchOS 7.0, *) { | ||
// This measures how long it takes to launch your application. | ||
measure(metrics: [XCTApplicationLaunchMetric()]) { | ||
XCUIApplication().launch() | ||
} | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
ConfidenceDemoApp/ConfidenceDemoAppUITests/ConfidenceDemoAppUITestsLaunchTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import XCTest | ||
|
||
@testable import ConfidenceDemoApp | ||
|
||
final class ConfidenceDemoAppUITestsLaunchTests: XCTestCase { | ||
override class var runsForEachTargetApplicationUIConfiguration: Bool { | ||
true | ||
} | ||
|
||
override func setUpWithError() throws { | ||
try super.setUpWithError() | ||
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
script_dir=$(dirname $0) | ||
root_dir="$script_dir/../" | ||
|
||
# Set the client token in your local keychain using the following command: | ||
# security add-generic-password -s 'swift-provider-e2e' -a 'confidence-test' -w 'TOKEN' | ||
# You can then run the script with no arguments - you will need to allow access the first time only. | ||
test_runner_client_token=$1 | ||
if [[ -z "${test_runner_client_token// }" ]]; then | ||
test_runner_client_token=$(security find-generic-password -w -s 'swift-provider-e2e' -a 'confidence-test') | ||
fi | ||
|
||
(cd $root_dir && | ||
TEST_RUNNER_CLIENT_TOKEN=$test_runner_client_token TEST_RUNNER_TEST_FLAG_NAME=$2 xcodebuild \ | ||
-quiet \ | ||
-scheme ConfidenceDemoApp \ | ||
-destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' \ | ||
test) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual test logic