Skip to content

Enable running WordPressShared unit tests from Xcode and using Xcode MCP#25370

Open
kean wants to merge 1 commit intotrunkfrom
task/fix-test-plans
Open

Enable running WordPressShared unit tests from Xcode and using Xcode MCP#25370
kean wants to merge 1 commit intotrunkfrom
task/fix-test-plans

Conversation

@kean
Copy link
Contributor

@kean kean commented Mar 12, 2026

Problem

  1. For some target like WordPressShared, Xcode has two shared schemes instead of one:
Screenshot 2026-03-12 at 8 51 05 AM
  1. Neither of those schemes are configured for testing. The (WordPress project) one is, but it asks you to select a module it belongs to (it doesn't know). It won't let you pick WordPressShared either.
Screenshot 2026-03-12 at 8 53 46 AM
  1. There are remnants on a test plan for WordPressShared, but they are broken
Screenshot 2026-03-12 at 8 55 04 AM

As a result, neither you not CC can run unit tests for individual targets using Xcode UI and/or Xcode MCP

Solution

  1. Remove the duplicates schemes – keep only the "(Module)" one to match other targets
  2. Add a working test plan to ./TestPlans/ (happy to discuss alternatives)
  3. Configure the remaining scheme to use this test plan
Screenshot 2026-03-12 at 9 03 42 AM

Result

Screenshot 2026-03-12 at 8 59 09 AM

Future Changes

Update the rest of the schemes for the interval SwiftPM module in the same fashion to allow testing them directly from Xcode and using Xcode MCP.

@kean kean added this to the Someday milestone Mar 12, 2026
@kean kean added the General label Mar 12, 2026
@kean kean requested review from jkmassel and mokagio March 12, 2026 13:10
@sonarqubecloud
Copy link

@wpmobilebot
Copy link
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number31436
VersionPR #25370
Bundle IDorg.wordpress.alpha
Commite6835fd
Installation URL4uh55gr38r5po
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number31436
VersionPR #25370
Bundle IDcom.jetpack.alpha
Commite6835fd
Installation URL5sd0n0kftkrh0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

Copy link
Contributor

@jkmassel jkmassel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good plan, but WDYT about putting the xctestplan in the WordPressSharedTests directory? That way each of these is colocated with their tests.

@kean
Copy link
Contributor Author

kean commented Mar 12, 2026

This seems like a good plan, but WDYT about putting the xctestplan in the WordPressSharedTests directory? That way each of these is colocated with their tests.

I've considered this option. AI recommendation was the following:

image

I can't really think of strong pros and cons for either of the the options. For example, if the plans are not colocated, you can still pretty easily find all of the available plans using a filter:

Screenshot 2026-03-12 at 12 50 23 PM

It looks like we already have some module-specific plans colocated, so I'll update it and follow the current practice.

(Existing WordPressShared plan from the screenshot is broken btw)

Copy link
Contributor

@mokagio mokagio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. I second @jkmassel 's comment regarding having the plan live in the same folder as the tests is manages.

I can see the value of a dedicated folder for plans if they were to combine different targets or different paths across targets, but since this is just an unfortunate requirement for testability with Xcode schemes, and the plan maps the whole tests target 1:1, it seems better for it to live in the same folder as the tests.

Anyways, looks like @kean already planned to address, so I'm preaching to the convert.

@kean
Copy link
Contributor Author

kean commented Mar 13, 2026

Hmm, turns out, it's not as simple. The removal of ./WordPress/WordPress.xcodeproj/xcshareddata/xcschemes/WordPressShared.xcscheme was fine. There is always an auto-created scheme in ./Modules/.swiftpm/xcode/xcshareddata/xcschemes/WordPressReader.xcscheme. Unfortunately, the latter is in .gitignore.

The tests I configured briefly worked, but stopped after module reset.

The root cause is somewhere else. For some, reason the auto-created scheme for JetpackStats can find its respective tests.

Screenshot 2026-03-13 at 8 29 00 AM

The WordPressShared scheme can't.

Screenshot 2026-03-13 at 8 29 08 AM

I cleared cache and re-created the auto-created schemes and it was still the case.

It's a bit confusing that these schemes are marked as shared but are in .gitignore, so nothing gets shared.

Screenshot 2026-03-13 at 8 39 56 AM

@kean
Copy link
Contributor Author

kean commented Mar 13, 2026

Since I recreated all the SwiftPM module schemes, JetpackStats tests also stopped working. Xcode now seems to put tests under Modules-Package by default.

Screenshot 2026-03-13 at 12 18 27 PM

I think what we might need to do is remove ./Modules/.swiftpm/xcode/xcshareddata/xcschemes from .gitignore and configure them properly for testing.

@mokagio
Copy link
Contributor

mokagio commented Mar 16, 2026

I think what we might beed to do is remove ./Modules/.swiftpm/xcode/xcshareddata/xcschemes from .gitignore and configure them properly for testing.

That would have been my guess, too. However, what would happens once SwiftPM regenerates them?

@kean
Copy link
Contributor Author

kean commented Mar 18, 2026

However, what would happens once SwiftPM regenerates them?

Presumably, it won't if it's shared. I'm going to give it a try. There must be a way to build and tests individual modules from Xcode for its MCP. It's a huge impediment when you are making module-specific changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants