Problem:
Test plans don’t execute with tuist test --test-plan PrimaryTests.xctestplan MyApp-Main, but work fine in Xcode. Other schemes without test plans work normally with tuist test.
Command:
bash
tuist test --test-plan PrimaryTests.xctestplan MyApp-Main
tuist test --test-plan PrimaryTests.xctestplan MyApp-Main doesn’t execute tests
Test plans are only in MyApp-Main scheme
Question:
Why do test plans prevent tuist test from executing tests when they work fine in Xcode? Is there a specific requirement for test plans with Tuist?
Note: Testplan already have the targets specofied correctly.
tuist test should work seamlessly with test plans – sorry to hear it’s not the case for you. We’ll need a bit more information to debug this, ideally a full reproducer.
If a reproducer is too complex, I’d also suggest checking:
This fixture that showcases a project with a test plan
run the tuist test command with —generate-only – do you see the test plan in the generated project?
Could the containerPath pointing at project-local .xcodeproj files have any impact when Tuist executes the test plan?
Xcode handles these container paths fine, but I’m wondering if Tuist expects test plan targets to use a different or more “global” path format.
Let me know if this might be related or if you want a minimal reproducer.
ensure the containerPath is pointing to the .xcodeproj relative to the root
Now, we should definitely handle your scenario more gracefully, but this could help nail down the issue.
Alternatively, I’d try to change the containerPath of the test plan to be relative to the test plan location when the test plan is in the same directory as the project, like we have in this fixture.
A reproducer would still be amazing. You might be able to reproduce your setup and the issue with one of the fixtures I linked – reproducers help a ton in fixing issues like this.
Also, just double checking – what Tuist version are you on? If not the latest, I’d suggest to update first.
I tried setting up a minimal reproducer using the same multi-project structure, but I wasn’t able to reproduce the issue. In the sample setup, Tuist successfully located and executed the test plan — even when I matched the folder hierarchy and placed the test plan at the workspace root.
In our actual project, though, Tuist still doesn’t seem able to resolve the test plan paths during tuist test, even after moving the test plan to the root and adjusting the containerPath values. Xcode continues to pick it up without any issues.
One more detail that might help:
If I run the tests directly using an xcodebuild command and pass the exact same test plan, it works fine. So the test plan itself is valid, and the issue appears to be tied specifically to how Tuist interprets our project layout or resolves paths inside the test plan.
I’ll continue trying to isolate the issue, and if I manage to extract a proper reproducible example, I’ll share it.
Thanks @muneerkk66. I checked your project, and it turns out you have a typo in the path to the test plan. It should be Testplan/UnitTests.xctestplan and not TestPlans/UnitTests.xctestplan. Once you change that, you’ll notice that if you run tuist generate, the scheme MainApp-Scheme will contain the test plan.
You’ll also have to add build targets to the scheme, otherwise there’s nothing to build. Note that the targets that need to build are not infered from your test plan, hence why you need to be explicit about it.
Thanks a lot for checking the project and pointing that out!
You’re absolutely right — the issue was a typo in the test plan path (my bad). After updating it to Testplan/UnitTests.xctestplan, the test plan now appears correctly in the MainApp-Scheme when running tuist generate.
Also, is there anywhere else where I should be configuring location settings?
Some of my data tests are failing due to location and region formatting issues, but they work correctly when I run them through the test plan.
It feels like I might be missing a configuration somewhere. I’ve already added the region via the test plan options — is there anything else I should be setting (for example at the scheme, target, or environment level)?
If you are using test plans, the location is defined in the test plan itself, which you can edit through Xcode’s UI once you generate the project pointing to it. If you are not using test plans, then you have to create a custom scheme. There you can include the testable targets in the test action with a simulated location set on it.