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

Bug: Unit Tests with multiple deps are not showing tests in Xcode.IDETestNavigator #3064

Open
themz opened this issue Aug 1, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@themz
Copy link

themz commented Aug 1, 2024

Description

Hello, I am trying to use ios_unit_test with multiple static libraries as dependencies. The test code is located in these static libraries. The issue I am facing is that there is a missing reference to the particular tests in the Xcode Test Navigator.

In the attached project, when I run the tests using Bazel, the results look good: all unit tests are executed.

However, when I open Xcode after generating the project, no tests are visible in the Xcode Test Navigator.
before_run

If I run all tests using Cmd+U or click on "All Tests" in the Xcode Test Navigator, the tests are detected at runtime:
after_run

However, if I try to run only one test, no tests are executed, but this empty execution is reported as successful.

When I keep only one dependency for ios_unit_test and regenerate the project, everything works as expected.
only_one_deps

I would be happy to work on this, but I need some help with direction. So far, I believe the issue occurs during the index build. I have tried to find the difference in how apple_rules handles one vs. multiple dependencies for unit tests, but I have not found any differences yet.

simple-unit-test-example.zip

Reproduction steps

In the attached project run

  1. bazel run //:a_and_b_xcodeproj
  2. Open Xcode Test Navigator

Expected behavior

To be able to see and run any particular unit test from Xcode test navigator.

rules_xcodeproj version

2.5.2

Xcode version

15.4 (15F31d)

Bazel version

7.2.1

rules_apple version

3.6.0

rules_swift version

2.1.1

Additional information

No response

@themz themz added the bug Something isn't working label Aug 1, 2024
@brentleyjones
Copy link
Contributor

This is expected. If the test has multiple deps, then rules_xcodeproj can’t merge the libraries into the top-level target. We can’t merge multiple same-language targets into a top-level target because they have different compiler flags, in particular different module names. And when the top-level target doesn’t have the source files associated with it, then it Xcode index the tests and doesn’t show the gutter diamonds or the tests in the navigator. After one run of the tests though Xcode sees them as dynamic tests and shows them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants