优化 UI Test 路由直达与会话复用,提升自定义 TabBar 下的稳定性。
新增启动参数直达首页与个人中心页面,引入 AppUITestRouteDriver 与 UITestSession 共享登录,并重构各模块用例的导航断言逻辑。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -11,26 +11,45 @@ import XCTest
|
||||
enum UITestLaunchConfiguration {
|
||||
static let uiTestsArgument = "-suixinkan-ui-tests"
|
||||
static let resetArgument = "-suixinkan-ui-tests-reset-state"
|
||||
static let openMenuArgument = "-suixinkan-ui-tests-open-menu"
|
||||
static let openProfileArgument = "-suixinkan-ui-tests-open-profile"
|
||||
|
||||
/// 生成 UI Test 启动参数;可用 openMenu / openProfile 直达目标页。
|
||||
static func launchArguments(
|
||||
resetState: Bool = false,
|
||||
openMenu: String? = nil,
|
||||
openProfile: String? = nil
|
||||
) -> [String] {
|
||||
var arguments = [uiTestsArgument]
|
||||
if resetState {
|
||||
arguments.append(resetArgument)
|
||||
}
|
||||
if let openMenu, !openMenu.isEmpty {
|
||||
arguments.append(contentsOf: [openMenuArgument, openMenu])
|
||||
} else if let openProfile, !openProfile.isEmpty {
|
||||
arguments.append(contentsOf: [openProfileArgument, openProfile])
|
||||
}
|
||||
return arguments
|
||||
}
|
||||
|
||||
/// 为 XCUIApplication 注入 UI Test 启动参数;仅在需要冷启动空白态时传入 resetState。
|
||||
static func apply(
|
||||
to app: XCUIApplication,
|
||||
resetState: Bool = false,
|
||||
openMenu: String? = nil,
|
||||
openProfile: String? = nil
|
||||
) {
|
||||
app.launchArguments = launchArguments(
|
||||
resetState: resetState,
|
||||
openMenu: openMenu,
|
||||
openProfile: openProfile
|
||||
)
|
||||
}
|
||||
|
||||
static let phoneEnvironmentKey = "SUI_TEST_PHONE"
|
||||
static let passwordEnvironmentKey = "SUI_TEST_PASSWORD"
|
||||
static let accountNameEnvironmentKey = "SUI_TEST_ACCOUNT_NAME"
|
||||
|
||||
/// 为 XCUIApplication 注入 UI Test 启动参数;仅在需要冷启动空白态时传入 resetState。
|
||||
static func apply(to app: XCUIApplication, resetState: Bool = false) {
|
||||
if !app.launchArguments.contains(uiTestsArgument) {
|
||||
app.launchArguments.append(uiTestsArgument)
|
||||
}
|
||||
|
||||
if resetState {
|
||||
if !app.launchArguments.contains(resetArgument) {
|
||||
app.launchArguments.append(resetArgument)
|
||||
}
|
||||
} else {
|
||||
app.launchArguments.removeAll { $0 == resetArgument }
|
||||
}
|
||||
}
|
||||
|
||||
/// 从 Scheme / xcodebuild 环境变量或本地 plist 读取测试账号。
|
||||
static var credentials: UITestCredentials? {
|
||||
if let environmentCredentials = credentialsFromEnvironment() {
|
||||
|
||||
Reference in New Issue
Block a user