Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-62471

Xcode Plugin - Unable to run Unit Tests

    XMLWordPrintable

Details

    Description

      Plugin version: 2.0.6
      Xcode version: 11.3.1
      Issue:
      I am following the exact same steps to set up unit tests via Xcode plugin but it doesn't work. Throws the error saying: 

      {{xcodebuild: error: Failed to build workspace MyWorkspace with scheme My-scheme.Reason: The scheme 'My-scheme' is not configured for Running.

      It runs perfectly while using xcodebuild test CLI command but I would like to see if it is possible via Plugin to maintain consistency. }}

      Setting up a unit test step

      Add the XCode build step and this time specify your unit test target (e.g. MyAppTests), configuration (e.g. Debug) and the SDK (e.g. Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/).
      Leave all the checkboxes unselected. The SDK needs to be supplied here as the unit tests will only be run when building under the simulator's SDK.

      Attachments

        Activity

          urmil025 Urmil Shah added a comment -

          I don't know how you installed it but I am running xcpretty with --report option and it is just fine. Try doing so locally, running the entire command with xcpretty, and see if that helps. 

          urmil025 Urmil Shah added a comment - I don't know how you installed it but I am running xcpretty with --report option and it is just fine. Try doing so locally, running the entire command with xcpretty, and see if that helps. 
          pinkeshgjr Pinkesh added a comment - - edited

          urmil025 I am using Jenkins locally. I tried adding -r junit in Custom xcodebuild arguments. Still same error, lool like xcpretty is not working with Jenkins. Is there any additional setup have you done?

          -allowProvisioningUpdates -enableCodeCoverage YES ONLY_ACTIVE_ARCH=YES test -list | xcpretty --report junit && exit ${PIPESTATUS[0]}

          pinkeshgjr Pinkesh added a comment - - edited urmil025  I am using Jenkins locally. I tried adding -r junit in Custom xcodebuild arguments. Still same error, lool like xcpretty is not working with Jenkins. Is there any additional setup have you done? -allowProvisioningUpdates -enableCodeCoverage YES ONLY_ACTIVE_ARCH=YES test -list | xcpretty --report junit && exit ${PIPESTATUS [0] }
          pinkeshgjr Pinkesh added a comment - - edited

          urmil025 i just removed xcode from jenkins and added execute shell command in configuration and it works fine.

          xcodebuild -workspace myproject.xcworkspace -scheme myprojectTests -destination 'platform=iOS Simulator,name=iPhone 12 Pro' -enableCodeCoverage YES test | xcpretty --report junit && exit ${PIPESTATUS[0]}

          Now i am facing some other issue like below. 
          xcodebuild[99034:318512] NSFileHandle couldn't write. Exception: *** -[_NSStdIOFileHandle writeData:]: Broken pipe

          pinkeshgjr Pinkesh added a comment - - edited urmil025  i just removed xcode from jenkins and added execute shell command in configuration and it works fine. xcodebuild -workspace myproject.xcworkspace -scheme myprojectTests -destination 'platform=iOS Simulator,name=iPhone 12 Pro' -enableCodeCoverage YES test | xcpretty --report junit && exit ${PIPESTATUS [0] } Now i am facing some other issue like below.  xcodebuild [99034:318512] NSFileHandle couldn't write. Exception: *** - [_NSStdIOFileHandle writeData:] : Broken pipe
          urmil025 Urmil Shah added a comment -

          That seems to be something in your code. I see some solutions on Stackoverflow. 

          urmil025 Urmil Shah added a comment - That seems to be something in your code. I see some solutions on Stackoverflow. 
          pinkeshgjr Pinkesh added a comment -

          urmil025 There was issue with path. It works fine now but is there any way to generate code coverage report?

           

          xcodebuild -workspace MyProject.xcworkspace -scheme MyProjectTests -destination 'platform=iOS Simulator,name=iPhone 12 Pro' -derivedDataPath DerivedData/ -enableCodeCoverage YES test | /usr/local/bin/xcpretty --report junit --output test-reports/reports.xml && exit ${PIPESTATUS[0]}

          pinkeshgjr Pinkesh added a comment - urmil025  There was issue with path. It works fine now but is there any way to generate code coverage report?   xcodebuild -workspace MyProject.xcworkspace -scheme MyProjectTests -destination 'platform=iOS Simulator,name=iPhone 12 Pro' -derivedDataPath DerivedData/ -enableCodeCoverage YES test | /usr/local/bin/xcpretty --report junit --output test-reports/reports.xml && exit ${PIPESTATUS [0] }

          People

            Unassigned Unassigned
            urmil025 Urmil Shah
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: