Skip to content

Commit 2046d8a

Browse files
authored
[PM-27049] Initial version of the Test Harness app (#2142)
1 parent 820865c commit 2046d8a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1552
-0
lines changed

Bitwarden.xcworkspace/contents.xcworkspacedata

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

Configs/Common-bwth.xcconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CODE_SIGN_STYLE = Automatic
2+
DEVELOPMENT_TEAM = LTZ2PFU5D6
3+
ORGANIZATION_IDENTIFIER = com.bitwarden
4+
BASE_BUNDLE_ID = $(ORGANIZATION_IDENTIFIER).testharness
5+
SHARED_APP_GROUP_IDENTIFIER = group.${ORGANIZATION_IDENTIFIER}.testharness
6+
APPICON_NAME = AppIcon
7+
8+
// The above code signing settings can be overriden by adding a Local-bwth.xcconfig
9+
// file in the Configs directory.
10+
//
11+
// As an example, add the file Local-bwth.xcconfig with the following contents:
12+
//
13+
// DEVELOPMENT_TEAM = <Your team ID>
14+
// ORGANIZATION_IDENTIFIER = <Your reversed domain name>
15+
// PROVISIONING_PROFILE_SPECIFIER = <Optional provisioning profile specifier for the main app>
16+
//
17+
// This should allow Xcode to build the application based on these settings without
18+
// code signing errors or having to modify the project itself.
19+
//

Configs/TestHarness-Debug.xcconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "./Common-bwth.xcconfig"
2+
#include "./Base-Debug.xcconfig"
3+
#include? "./Local-bwth.xcconfig"
4+
5+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
6+
CODE_SIGN_ENTITLEMENTS = TestHarness/Application/Support/Entitlements/TestHarness.entitlements
7+
PRODUCT_BUNDLE_IDENTIFIER = $(BASE_BUNDLE_ID)
8+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) PREVIEWS $(BITWARDEN_FLAGS)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "./Common-bwth.xcconfig"
2+
#include "./Base-Release.xcconfig"
3+
#include? "./Local-bwth.xcconfig"
4+
5+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
6+
CODE_SIGN_ENTITLEMENTS = TestHarness/Application/Support/Entitlements/TestHarness.entitlements
7+
PRODUCT_BUNDLE_IDENTIFIER = $(BASE_BUNDLE_ID)
8+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) $(BITWARDEN_FLAGS)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "./Common-bwth.xcconfig"
2+
#include "./Base-Debug.xcconfig"
3+
#include? "./Local-bwth.xcconfig"
4+
5+
PRODUCT_BUNDLE_IDENTIFIER = $(BASE_BUNDLE_ID).testharness-shared
6+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) $(BITWARDEN_FLAGS)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "./Common-bwth.xcconfig"
2+
#include "./Base-Release.xcconfig"
3+
#include? "./Local-bwth.xcconfig"
4+
5+
PRODUCT_BUNDLE_IDENTIFIER = $(BASE_BUNDLE_ID).testharness-shared
6+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) $(BITWARDEN_FLAGS)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Foundation
2+
3+
/// Global test helpers for TestHarness tests.
4+
///
5+
/// This file provides shared testing utilities used across the TestHarness test suite.

README-bwth.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Test Harness
2+
3+
A playground application for testing and demonstrating various Bitwarden iOS features and flows.
4+
5+
## Overview
6+
7+
The Test Harness app provides a simple interface to trigger and test different scenarios within the Bitwarden iOS ecosystem, including:
8+
9+
- Password Autofill flows
10+
- Passkey Autofill flows (coming soon)
11+
- Passkey Creation flows (coming soon)
12+
13+
## Purpose
14+
15+
This app is designed for:
16+
- Manual testing of specific flows
17+
- Demonstrating feature functionality
18+
- Debugging and development
19+
- Integration testing scenarios
20+
21+
## Structure
22+
23+
The app follows the same architectural patterns as the main Bitwarden apps:
24+
- Coordinator-based navigation
25+
- Processor/State/Action/Effect pattern for views
26+
- Service container for dependency injection
27+
- Sourcery for mock generation
28+
29+
## Building
30+
31+
The Test Harness is part of the main iOS workspace. To build:
32+
33+
1. Run `./Scripts/bootstrap.sh` to generate the Xcode project
34+
2. Open `Bitwarden.xcworkspace`
35+
3. Select the `TestHarness` scheme
36+
4. Build and run
37+
38+
## Note
39+
40+
This is a development/testing tool and is not intended for production use or App Store distribution.

Scripts/bootstrap.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ repo_root=$(dirname "$script_dir")
1313
mint run xcodegen --spec "$repo_root/project-bwk.yml"
1414
mint run xcodegen --spec "$repo_root/project-pm.yml"
1515
mint run xcodegen --spec "$repo_root/project-bwa.yml"
16+
mint run xcodegen --spec "$repo_root/project-bwth.yml"
1617
echo "✅ Bootstrapped!"
1718

1819
# Check Xcode version matches .xcode-version
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import BitwardenKit
2+
import TestHarnessShared
3+
import UIKit
4+
5+
/// A protocol for an `AppDelegate` that can be used by the `SceneDelegate` to look up the
6+
/// `AppDelegate` when the app is running (`AppDelegate`) or testing (`TestingAppDelegate`).
7+
protocol AppDelegateType: AnyObject {
8+
/// The processor that manages application level logic.
9+
var appProcessor: AppProcessor? { get }
10+
11+
/// Whether the app is running for unit tests.
12+
var isTesting: Bool { get }
13+
}
14+
15+
/// The app's `UIApplicationDelegate` which serves as the entry point into the app.
16+
class AppDelegate: UIResponder, UIApplicationDelegate, AppDelegateType {
17+
// MARK: Properties
18+
19+
/// The processor that manages application level logic.
20+
var appProcessor: AppProcessor?
21+
22+
/// Whether the app is running for unit tests.
23+
var isTesting: Bool {
24+
ProcessInfo.processInfo.arguments.contains("-testing")
25+
}
26+
27+
// MARK: Methods
28+
29+
func application(
30+
_: UIApplication,
31+
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil,
32+
) -> Bool {
33+
// Exit early if testing to avoid running any app functionality.
34+
guard !isTesting else { return true }
35+
36+
let services = ServiceContainer()
37+
let appModule = DefaultAppModule(services: services)
38+
appProcessor = AppProcessor(appModule: appModule, services: services)
39+
return true
40+
}
41+
}

0 commit comments

Comments
 (0)