我在项目中有一些全局常量:
// DemoACIs.swift
let DEMO_TEST_MENU_SCREEN_VIEW_ACI = "test_menu_screen_view"
let DEMO_TEST_MENU_SCREEN_TITLE_LABEL_ACI = "test_menu_screen_title_label"
let DEMO_TEST_MENU_SCREEN_BUTTON1_ACI = "test_menu_screen_button1"
etc.
我想在Xcode中另一个基于Swift的目标(在这种情况下是一个UI测试目标)中引用它们......
// TestMenuScreenViewProxy.swift
import Foundation
import XCTest
class TestMenuScreenViewProxy
{
internal var view:XCUIElement { return app.otherElements[DEMO_TEST_MENU_SCREEN_VIEW_ACI] }
internal var titleLabel:XCUIElement { return app.textFields[DEMO_TEST_MENU_SCREEN_TITLE_LABEL_ACI] }
internal var button1:XCUIElement { return app.buttons[DEMO_TEST_MENU_SCREEN_BUTTON1_ACI] }
}
当然这不起作用。在测试目标中找不到常量。如何在目标中访问它们?
答案 0 :(得分:4)