• Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • xcode-plugin

      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.

          [JENKINS-62471] Xcode Plugin - Unable to run Unit Tests

          Pinkesh added a comment - - edited

          urmil025 Just tried using that command now i am getting this error.
          -allowProvisioningUpdates -enableCodeCoverage YES ONLY_ACTIVE_ARCH=YES test -list xcodebuild ... | xcpretty --report junit && exit ${PIPESTATUS[0]}
          xcodebuild: error: invalid option '–report'

          i have added this in Custom xcodebuild arguments. Let me know if i am doing it wrong.

          Pinkesh added a comment - - edited urmil025  Just tried using that command now i am getting this error. -allowProvisioningUpdates -enableCodeCoverage YES ONLY_ACTIVE_ARCH=YES test -list xcodebuild ... | xcpretty --report junit && exit ${PIPESTATUS [0] } xcodebuild: error: invalid option '–report' i have added this in Custom xcodebuild arguments. Let me know if i am doing it wrong.

          Urmil Shah added a comment -

          Just add  

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

          This will need you to have xcpretty installed on the machine. Find more details here - https://github.com/xcpretty/xcpretty 

          Urmil Shah added a comment - Just add   -allowProvisioningUpdates -enableCodeCoverage YES ONLY_ACTIVE_ARCH=YES test -list | xcpretty --report junit && exit ${PIPESTATUS[0]} This will need you to have xcpretty installed on the machine. Find more details here - https://github.com/xcpretty/xcpretty  

          Pinkesh added a comment -

          urmil025 i just tried replacing command that you shared also installed xcpretty with this command 

          gem install xcpretty.

          Still getting same error, do i need to adding any plugin?

          Pinkesh added a comment - urmil025  i just tried replacing command that you shared also installed  xcpretty  with this command  gem install xcpretty. Still getting same error, do i need to adding any plugin?

          Urmil Shah added a comment -

          What is your full command? Also, try running only

           xcpretty --help

          in your build and see if Jenkins recognizes it. you might need to specify the entire path or add it to your bash file. 

          Urmil Shah added a comment - What is your full command? Also, try running only xcpretty --help in your build and see if Jenkins recognizes it. you might need to specify the entire path or add it to your bash file. 

          Pinkesh added a comment - - edited

          urmil025 i just tried adding xcpretty --help and Jenkins recognise it. There is no command --report

          Pinkesh added a comment - - edited urmil025  i just tried adding xcpretty --help and Jenkins recognise it. There is no command --report

          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. 

          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. 

          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]}

          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] }

          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

          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

          Urmil Shah added a comment -

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

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

          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]}

          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] }

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

              Created:
              Updated: