Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find any .xccoverage file #30

Open
weemundo opened this issue Dec 7, 2019 · 2 comments
Open

Unable to find any .xccoverage file #30

weemundo opened this issue Dec 7, 2019 · 2 comments

Comments

@weemundo
Copy link

weemundo commented Dec 7, 2019

Hi All,

I am trying to run Danger xcov on my Gitlab CI using the following:

xcov.report(
scheme: 'Scheme_Name'
)

I am getting the following error:

[00:24:44]: Unable to find any .xccoverage file.
[00:24:44]: Make sure you have enabled 'Gather code coverage' setting on your scheme settings.
[00:24:44]: Alternatively you can provide the full path to your .xccoverage file.
[!] The exception involves the following plugins:

  • danger-xcov
    bundler: failed to load command: danger (/Users/ios_testing/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bin/danger)
    Danger::DSLError:
    [!] Invalid Dangerfile file: Error processing coverage file - see the log above. Updating the Danger gem might fix the issue. Your Danger version: 6.0.7, latest Danger version: 6.1.0

However when I run the following command on CI:

xcrun xcov --scheme Scheme_Name --verbose

It successfully generates the report.

I am currently using XCode 11 and it generates .xcresult. Code coverage is turned on and I have tried setting the full path to the report as well but the plugin is unable to find it.

@chrisballinger
Copy link

As of Xcode 11 you need to preprocess the xcresult first: https://github.com/ChargePoint/xcparse#code-coverage

@Kaspik
Copy link

Kaspik commented Apr 26, 2020

So finally working solution for this would be something like this (I'm using Github Actions with Danger and build.sh script file called from the yaml file).

build.sh:

  bundle install
  pod install --repo-update
  set -o pipefail && bundle exec fastlane tests
  echo "Running Danger..."
  xcparse codecov ./fastlane/test_output/app.xcresult ./fastlane/test_coverage
  bundle exec fastlane danger_tests
  rm -fr ./fastlane/test_coverage
  rm -rf ./fastlane/build_folder

Fastfile:

  1. tests:
  desc "Runs app tests - UNIT + UI tests"
  lane :tests do\
    # First build the project to the build_folder directory
    run_tests(
      workspace: WORKSPACE_NAME,
      scheme: TARGET_NAME,
      derived_data_path: "./fastlane/build_folder",
      build_for_testing: true,
      device: "iPhone 11 Pro",
      code_coverage: true
    )
    # Then run tests without building the project itself
    run_tests(
      workspace: WORKSPACE_NAME,
      scheme: TARGET_NAME,
      derived_data_path: "./fastlane/build_folder",
      test_without_building: true,
      device: "iPhone 11 Pro",
      result_bundle: true,
      output_types: "html",
      prelaunch_simulator: true,
      code_coverage: true
    )
  end
  1. danger_tests:
desc "Run Danger check for tests coverage"
  lane :danger_tests do |options|
    danger(
        danger_id: "Tests",
        dangerfile: "DangerfileBuild",
        github_api_token: ENV["GITHUB_API_TOKEN"]
    )
  end
  1. DangerfileBuild:
xcov.report(
   scheme: 'TARGET_NAME',
   workspace: 'WORKSPACE_NAME',
   output_directory: 'xcov_output',
   only_project_targets: true
)

As you can see, the problem here is that I have to run xcparse codecov ./fastlane/test_output/app.xcresult ./fastlane/test_coverage ro get the right file from build folder as xcov works on build folder, but danger-xcov is not updated for that.

Would be nice to update this project.
@joshdholtz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants