Context
When running the tuist test
command, a Workspace is generated with a focus on the targets that will participate in the build process.
This approach has several drawbacks:
- Inability to run tests in parallel for multiple platforms.
- Incorrect behavior when trying to explicitly pass a list of test targets via the
--test-targets
argument
1. Parallel testing
It is quite convenient to implement parallel execution of pipeline steps independent of each other on CI.
One of such scenarios is the deployment of cross-platform applications (for example, iOS and tvOS).
Currently, I use fastlane scan
for testing and it works.
But I would like to switch to tuist test
, which allows running tests selectively. Because of that, calling the command re-generates the project’s xcodeproj
files - this can lead to a race condition and conflicts in the build processes.
2. Manually passing the list of targets
I have a script that allows generating XCTestPlan in which all unit-test targets that are in the workspace are, using gem xcodeproj
.
I am thinking of abandoning the testPlan generation and passing the entire list via the --test-targets
flag, but I encountered unexpected behavior (I don’t know, maybe it’s a bug):
- At the first launch, everything works correctly
- At the second launch, focusing occurs, excluding test targets on which tests were previously launched.
This results in an error:
The following targets were not found: A, B, C
Deleting the ~/.cache/tuist/SelectiveTests
folder fixes the error, but deletes the cache
This behavior seems contradictory and requires (in the current situation) a premature error: --test-targets
cannot be used together with --selective-testing
Proposed solution
Do not modify the initial project graph that was generated by the tuist generate
command. In theory, this should solve both problems.
The second problem, with running all tests, however, can be solved by modifying the CLI, allowing you to run tests with a filter on the platform:
There is already an argument --platform
that specifies the platform for which the scheme should be built. You can try to extend the behavior as follows:
if the scheme, testing-targets, test-plan are not passed, then the platform parameter will be used as a filter for all workspace test-targets.