Skip to content
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

XCUITest and XCTest did not run #826

Open
ken4ward opened this issue Jan 10, 2024 · 3 comments
Open

XCUITest and XCTest did not run #826

ken4ward opened this issue Jan 10, 2024 · 3 comments

Comments

@ken4ward
Copy link

While trying to run both XCTest and XCUITest, the best the runner did was to launch the simulator, but did not run the tests. What are the changes I need to make to complete running?

BUILD.bazel file

load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load("@build_bazel_rules_ios//rules:test.bzl", "ios_unit_test")
load("@build_bazel_rules_ios//rules:test.bzl", "ios_ui_test")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")

swift_library(
    name = "lib",
    srcs = glob(["BazelPro/*.swift"]),
)

swift_library(
    name = "unittestlib",
    srcs = glob(["BazelProTests/*.swift"]),
)

swift_library(
    name = "uitest",
    srcs = glob(["BazelProUITests/*.swift"]),
)

ios_application(
    name = "BazelPro",
    bundle_id = "mob.christdoes.nl.BazelPro",
    families = ["iphone","ipad",],
    infoplists = ["BazelPro/Info.plist"],
    minimum_os_version = "17.0",
    visibility = ["//visibility:public"],
    deps = [":lib"],
)

ios_unit_test(
    name = "BazelProTests",
    bundle_id = "mob.christdoes.nl.BazelProTests",
    minimum_os_version = "17.0",
    visibility = ["//visibility:public"],
    test_host = ":BazelPro",
    deps = [":unittestlib"],
    sdk_frameworks = ["XCTest"],
)

ios_ui_test(
    name = "BazelProUITests",
    bundle_id = "mob.christdoes.nl.BazelProUITests",
    minimum_os_version = "17.0",
    visibility = ["//visibility:public"],
    test_host = ":BazelPro",
    deps = [":uitest"],
    sdk_frameworks = ["XCUITest"],
)

Log report

bazel test --tool_tag=ijwb:IDEA:community --curses=no --color=yes --progress_in_terminal_title=no --build_event_binary_file=/var/folders/78/k56g5_1s17nb2ybq7_2f_gl00000gp/T/intellij-bep-a289f6b5-38b4-4702-b6aa-d86882278be3 --nobuild_event_binary_file_path_conversion -- //BazelPro:BazelProUITests
Testing started at 15:20 ...
Starting local Bazel server and connecting to it...
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Analyzing: target //BazelPro:BazelProUITests (1 packages loaded, 0 targets configured)
Analyzing: target //BazelPro:BazelProUITests (1 packages loaded, 0 targets configured)
[0 / 1] checking cached actions
Analyzing: target //BazelPro:BazelProUITests (60 packages loaded, 6 targets configured)
[1 / 1] checking cached actions
Analyzing: target //BazelPro:BazelProUITests (104 packages loaded, 1503 targets configured)
[1 / 1] checking cached actions
Analyzing: target //BazelPro:BazelProUITests (104 packages loaded, 1503 targets configured)
[1 / 1] checking cached actions
Analyzing: target //BazelPro:BazelProUITests (105 packages loaded, 1513 targets configured)
[1 / 1] checking cached actions
Analyzing: target //BazelPro:BazelProUITests (105 packages loaded, 1513 targets configured)
[1 / 1] checking cached actions
Analyzing: target //BazelPro:BazelProUITests (105 packages loaded, 1513 targets configured)
[1 / 1] checking cached actions
Analyzing: target //BazelPro:BazelProUITests (105 packages loaded, 1513 targets configured)
[1 / 1] checking cached actions
INFO: Analyzed target //BazelPro:BazelProUITests (113 packages loaded, 1660 targets configured).
[46 / 80] Compiling tools/common/process.cc [for tool]; 0s darwin-sandbox ... (11 actions, 10 running)
[58 / 80] Compiling tools/worker/worker_protocol.cc [for tool]; 1s darwin-sandbox ... (5 actions running)
[71 / 80] Compiling Swift module //BazelPro:lib; 0s worker ... (2 actions running)
[73 / 80] Compiling Swift module //BazelPro:lib; 1s worker
[74 / 80] [Prepa] Linking BazelPro/liblib.a
[80 / 81] [Prepa] Testing //BazelPro:BazelProUITests
[80 / 81] Testing //BazelPro:BazelProUITests; 1s darwin-sandbox
[80 / 81] Testing //BazelPro:BazelProUITests; 10s darwin-sandbox
[80 / 81] Testing //BazelPro:BazelProUITests; 40s darwin-sandbox
[80 / 81] Testing //BazelPro:BazelProUITests; 100s darwin-sandbox
[80 / 81] Testing //BazelPro:BazelProUITests; 161s darwin-sandbox
[80 / 81] Testing //BazelPro:BazelProUITests; 166s darwin-sandbox
INFO: Found 1 test target...
Target //BazelPro:BazelProUITests up-to-date:
  bazel-bin/BazelPro/BazelProUITests
  bazel-out/ios_sim_arm64-fastbuild-ios-sim_arm64-min17.0-applebin_ios-ST-8428403ac814/bin/BazelPro/BazelProUITests.zip
INFO: Elapsed time: 193.588s, Critical Path: 174.54s
INFO: 81 processes: 47 internal, 31 darwin-sandbox, 2 local, 1 worker.
INFO: Build completed successfully, 81 total actions
INFO: 
//BazelPro:BazelProUITests                                               PASSED in 166.9s

Executed 1 out of 1 test: 1 test passes.
INFO: Build Event Protocol files produced successfully.

Generated test.log (if the file is not UTF-8, then this may be unreadable):
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //BazelPro:BazelProUITests
-----------------------------------------------------------------------------
2024-01-10 14:21:19,165 Creating a new simulator:
Name: New-iPhone 15 Pro Max-17.2
OS: iOS 17.2
Type: iPhone 15 Pro Max
2024-01-10 14:21:19,968 Created new simulator 7529DB7A-8C37-485C-8E33-3B923043184B.
2024-01-10 14:21:20,988 The simulator 7529DB7A-8C37-485C-8E33-3B923043184B is booted.
2024-01-10 14:21:20,989 Generating xctestrun file.
2024-01-10 14:21:41,441 Running test-without-building with device 7529DB7A-8C37-485C-8E33-3B923043184B
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild test-without-building -xctestrun /var/folders/78/k56g5_1s17nb2ybq7_2f_gl00000gp/T/test_runner_work_dir.oAvycf/TEST_ROOT/test.xctestrun -destination id=7529DB7A-8C37-485C-8E33-3B923043184B -derivedDataPath /private/var/tmp/_bazel_kadeoya/8f94d19b21fb04df45058f260f5bad47/sandbox/darwin-sandbox/33/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/BazelPro/BazelProUITests/test.outputs -resultBundlePath /private/var/tmp/_bazel_kadeoya/8f94d19b21fb04df45058f260f5bad47/sandbox/darwin-sandbox/33/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/BazelPro/BazelProUITests/test.outputs/test.xcresult -collect-test-diagnostics=never

User defaults from command line:
    collect-test-diagnostics = never
    IDEBuildOperationResultBundlePath = /private/var/tmp/_bazel_kadeoya/8f94d19b21fb04df45058f260f5bad47/sandbox/darwin-sandbox/33/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/BazelPro/BazelProUITests/test.outputs/test.xcresult
    IDEDerivedDataPathOverride = /var/tmp/_bazel_kadeoya/8f94d19b21fb04df45058f260f5bad47/sandbox/darwin-sandbox/33/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/BazelPro/BazelProUITests/test.outputs
    IDEPackageSupportUseBuiltinSCM = YES

Writing result bundle at path:
	/private/var/tmp/_bazel_kadeoya/8f94d19b21fb04df45058f260f5bad47/sandbox/darwin-sandbox/33/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/BazelPro/BazelProUITests/test.outputs/test.xcresult

--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, id:7529DB7A-8C37-485C-8E33-3B923043184B, OS:17.2, name:New-iPhone 15 Pro Max-17.2 }
{ platform:iOS Simulator, id:7529DB7A-8C37-485C-8E33-3B923043184B, OS:17.2, name:New-iPhone 15 Pro Max-17.2 }
Testing started
    t =      nans Interface orientation changed to Portrait
Test Suite 'All tests' started at 2024-01-10 15:24:02.654.
Test Suite 'All tests' passed at 2024-01-10 15:24:02.655.
	 Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.001) seconds
2024-01-10 14:24:02.941 xcodebuild[55172:1991577] [MT] IDETestOperationsObserverDebug: 138.944 elapsed -- Testing started completed.
2024-01-10 14:24:02.942 xcodebuild[55172:1991577] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
2024-01-10 14:24:02.942 xcodebuild[55172:1991577] [MT] IDETestOperationsObserverDebug: 138.944 sec, +138.944 sec -- end

Test session results, code coverage, and logs:
	/var/tmp/_bazel_kadeoya/8f94d19b21fb04df45058f260f5bad47/sandbox/darwin-sandbox/33/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/BazelPro/BazelProUITests/test.outputs/test.xcresult

** TEST EXECUTE SUCCEEDED **

2024-01-10 14:24:03,277 Deleting simulator 7529DB7A-8C37-485C-8E33-3B923043184B asynchronously.
2024-01-10 14:24:03,287 Done.
      
@mattrobmattrob
Copy link
Collaborator

You could try passing the ios_ui_test sources directly to the target instead of the swift_library:

ios_ui_test(
    ...,
    srcs = glob(...),
    ...
)

If that doesn't work, please create a repro project/repo and we can take a look.

@ken4ward
Copy link
Author

@mattrobmattrob thank you. It gave the same result. Didn't work also.

@luispadron
Copy link
Collaborator

Without seeing the sources for your tests we wouldn't be able to help much, we use these rules internally and they definitely run the tests.

Could you create a small project that reproduces this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants