-
Notifications
You must be signed in to change notification settings - Fork 309
Closed
Description
Problem
Hi, I have an issue with properly declaring existing UI/Unit Tests targets in existing codebase in terms of ios_ui_test and ios_ui_test. For our targets we normally define NSPrincipalClass in Info.plist file corresponding to a UI/Unit test target. The class conforms to XCTestObservation and does initial setup before tests for corresponding target get executed. I can't figure out how to make this behaviour working with either of the rules. Is there a way to do it?
My BUILD file for a module:
# BUILD file
# ...
module_uitests_ios(
name = "MyUITestsTarget",
ios_app_dep = ":MyUITestsDemoDemoApp",
runner = "@build_bazel_rules_apple//apple/testing/default_runner:ios_xctestrun_ordered_runner",
deps = [
"//Modules/AccessibilityConstants",
"//Modules/TestConfiguration"
],
data = ["MyUITestsTarget/Info.plist"],
)
ios_demo_app(
name = "MyUITestsDemoDemoApp",
deps = [
":MyUITestsTarget",
"//Modules/DependencyInjection",
"//Modules/TestConfiguration",
],
)`My macros:
#.bzl file with macors
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test", "ios_ui_test")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
def ios_demo_app(
name,
deps = [],
data = [],
tags = [],
visibility = ["//visibility:public"]):
demo_app_name = name + "DemoApp"
demo_app_sources = demo_app_name + "Sources"
swift_library(
name = demo_app_sources,
module_name = demo_app_name,
srcs = native.glob([demo_app_name + "/**/*.swift"]),
deps = deps,
visibility = visibility,
data = data,
tags = tags,
)
ios_application(
name = demo_app_name,
bundle_id = "com.myapp." + demo_app_name,
families = [
"iphone",
"ipad",
],
minimum_os_version = "16.0",
infoplists = [":" + demo_app_name + "/Info.plist"],
deps = [
":" + demo_app_sources,
],
visibility = visibility,
tags = tags,
)
def module_uitests_ios(
name,
ios_app_dep,
runner,
visibility = ["//visibility:public"],
deps = [],
tags = [],
data = []):
swift_library(
name = "UITests",
testonly = True,
srcs = native.glob([
name + "UITests/**/*.swift"
]),
tags = ["manual"],
deps = [":" + name] + deps,
data = native.glob([name + "UITests/**/*.xcassets/**"], allow_empty = True)
)
ios_ui_test(
name = name + "_UITests",
minimum_os_version = "16.0",
runner = runner,
test_host = ios_app_dep,
deps = [":UITests"],
visibility = visibility,
data = data,
)The build process of the targets passes but unfortunately tests fail due to missing configuration step before all tests get run.
Metadata
Metadata
Assignees
Labels
No labels