Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B buck
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 201
    • Issues 201
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 22
    • Merge requests 22
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • buck
  • Issues
  • #2379
Closed
Open
Issue created Feb 03, 2020 by Administrator@rootContributor

Running Xcode UITests with Buck

Created by: rsacchi

Hi, I am trying to run Xcode UITests with buck, but still did not succeed. I have a project with many modules, and one module has a UITests target created with this rule:

apple_test(
  name = 'MyUITests',
  info_plist = 'MyUITests/Info.plist',
  srcs = glob(['MyUITests/**/*.m', 'MyUITests/**/*.swift']),
  labels = ['uitest'],
  is_ui_test = True,
  run_test_separately = True,
  test_host_app = '//Home:MyApp',
  deps = [
          '//Home/UITestsCore:UITestsCore',
          ':Resources'
          ],
  frameworks = [
    '$SDKROOT/System/Library/Frameworks/Foundation.framework',
    '$SDKROOT/System/Library/Frameworks/UIKit.framework',
  ],
)

test_host_app is the main bundle (that has this one as dependency). The project generates the UITests target correctly and I can run them successfully on Xcode. However, when I run buck test <MyUITests>, I get:

Testing: finished in 0.0 sec
RESULTS FOR //Path/To/Module:MyUITests
NO TESTS RAN

I also later tried to do it the same way as in this link: https://github.com/airbnb/BuckSample/blob/master/App/BUCK

apple_test_lib(
    name = "XCUITests",
    destination_specifier = {
        "name": "iPhone 8",
    },
    run_test_separately = True,
    # The `test_host_app` is launched first in the Simulator and needs to be an `apple_bundle` that is distinct from `ui_test_target_app`.
    test_host_app = ":XCUITestsHostApp",
    srcs = glob([
        "XCUITests/*.swift",
    ]),
    is_ui_test = True,
    # The `ui_test_target_app` field is not mentioned in Buck's official documentation, but it appears in its XCUITest fixtures.
    # https://github.com/facebook/buck/blob/master/test/com/facebook/buck/apple/testdata/apple_test_xcuitest/BUCK.fixture#L66
    ui_test_target_app = ":ExampleApp",
    labels = ['ui'],
    deps = [
        "//Libraries/ASwiftModule:ASwiftModule",
    ],
    frameworks = [
        "$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework",
        "$SDKROOT/System/Library/Frameworks/Foundation.framework",
        "$SDKROOT/System/Library/Frameworks/UIKit.framework",
    ],
)

But still didn't work. It launches the app but it fails to get automation session:

FAILURE SomeTests -[SomeTests testSomething]: <unknown>:0: Failed to get automation session for com.xxx.xxxx:26712: No bundle at path (null) 
====STANDARD OUT====
HostApp [26710:2606999] Can't end BackgroundTask: no background task exists with identifier 1 (0x1), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
   0.04s Set Up 
   0.06s Open com.xxx.xxxx 
   0.10s Launch com.xxx.xxxx 
   0.17s Setting up automation session 
   1.25s Assertion Failure: <unknown>:0: Failed to get automation session for com.xxx.xxxx:26712: No bundle at path (null) 
   1.27s Tear Down 
   1.27s Terminate com.xxx.xxxx: 26712

Can someone help me out? ui_test_target_app doesn't seem to be on the docs and I am struggling to find more examples using UITests on iOS projects.

Assignee
Assign to
Time tracking