XcodeSelectiveTesting icon indicating copy to clipboard operation
XcodeSelectiveTesting copied to clipboard

xcodebuild: error: Scheme SCHEME is not currently configured for the test action.

Open wei18 opened this issue 1 year ago • 2 comments

I encountered an issue where the xctestplan has 0 test case.

Is it acceptable to handle this situation in this way? Thanks.

wei18 avatar Dec 12 '24 06:12 wei18

Hey @Wei18 , I also encounted this; this is a tricky case, as the xcodebuild test process is returning a failure code. What I did in practice is to call the XcodeSelectiveTesting tool with --json flag, then parse the JSON and check if it has any targets:

      targets_affected_string = `mint run mikeger/XcodeSelectiveTesting --json --verbose --base-branch origin/$BITRISEIO_GIT_BRANCH_DEST`

      targets_affected = JSON.parse(targets_affected_string)

      if targets_affected.empty?
        UI.message "No targets to test. Skipping test."
        sh("envman add --key TESTS_SKIPPED --value \"true\"")
      else 
        UI.message "Targets affected directly: " + targets_affected.to_a.join(', ')

mikeger avatar Dec 16 '24 09:12 mikeger

Hey @mikeger, Thanks for this idea.

But your current method processes the test plan twice. Is it possible to provide a new command that can directly return the current number of test cases?

Like is pseudocode

mint run mikeger/XcodeSelectiveTesting testplan
mint run mikeger/XcodeSelectiveTesting --count testplan

wei18 avatar Dec 23 '24 04:12 wei18