8000 How generate code coverage report for Sonar for Cocoapod library? · Issue #8921 · CocoaPods/CocoaPods · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

How generate code coverage report for Sonar for Cocoapod library? #8921

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

Closed
facundor opened this issue Jun 19, 2019 · 7 comments · Fixed by #9302
Closed

How generate code coverage report for Sonar for Cocoapod library? #8921

facundor opened this issue Jun 19, 2019 · 7 comments · Fixed by #9302
Labels
d2:moderate A moderately-difficult ticket that may require a bit of knowledge about the codebase t1:enhancement Enhancements that have not been picked up yet. Please comment if you plan to work on it t4:question This is a question to the maintainers. This could lead into closing the issue or into an enhancement
Milestone

Comments

@facundor
Copy link
facundor commented Jun 19, 2019

Report

Hi everyone.

We are currently developing an iOS app, with multiple functional modules as cocoapod libraries. The modules are projects that compile separate from the app, and they are linked as cocoapod dependency in the application. We are developing unit tests with XCTest and we want upload test coverage to a Sonar Swift project. We have a sonar proyect per module and per application.

Here is the problem, because there is not guide about how to generate coverage report for a cocoapod library to Sonar. ¿There is a way to doing this with cocoapod? ¿There is a way to generate coverage reports in the pod lib lint process?

We run the "pod lib lint" in modules, runing unit test perfectly. But not coverage data generated.

Any help is appreciated

Cheers

What did you do?

ℹ Run pod lib lint

What did you expect to happen?

Generate coverage data like *.xccovarchive files to translate and upload to Sonar Swift project

What happened instead?

No coverage data generated.

CocoaPods Environment

Stack

   CocoaPods : 1.6.0
        Ruby : ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
    RubyGems : 2.5.2.3
        Host : Mac OS X 10.14.5 (18F132)
       Xcode : 10.2.1 (10E1001)
         Git : git version 2.19.2
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 19a3cd7c43acecddf9adfd79b47293ca176a3564
               company-specs - git@gitlab.company.dev:core-mobile/ios/specs.git @ sdsdf

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

cocoapods-deintegrate : 1.0.2
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.3.1
cocoapods-try         : 1.1.0

Podfile

# Cocoa repositories list
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_modular_headers!

target 'Core' do
    # Third party libraries
	pod 'Alamofire', '4.8.2'
	# Auth0
	pod 'Auth0', '1.15'
  	pod 'JWTDecode', '2.3.0'
	# Split.io
	pod 'Split', '2.3.0'
	# Google dependencies
  	pod 'Firebase', '6.2.0'
  	pod 'Firebase/Messaging', '6.2.0'
  	pod 'Firebase/MLVision', '6.2.0'
	pod 'Firebase/MLVisionLabelModel', '6.2.0' 
	pod 'Firebase/MLVisionBarcodeModel', '6.2.0'
	pod 'Firebase/Core', '6.2.0'
	pod 'Crashlytics',  '3.13.1'
	pod 'Fabric', '1.10.1'
	pod 'GoogleTagManager', '7.1.2'
	# Checkeo que de conexion a red
	pod 'ReachabilitySwift', '4.3.1'
	# Notificaciones push
	pod 'AWSCore', '2.9.9'
end
@dnkoutso dnkoutso added the t4:question This is a question to the maintainers. This could lead into closing the issue or into an enhancement label Jun 19, 2019
@dnkoutso
Copy link
Contributor

Hi there, thanks for asking. I do not think there is a way to generate code coverage today. Are you using test specs? What is the podspec you are working with?

If you are using test specs then we could extend the scheme DSL to add support for code coverage generation maybe.

@dnkoutso dnkoutso added d2:moderate A moderately-difficult ticket that may require a bit of knowledge about the codebase t1:enhancement Enhancements that have not been picked up yet. Please comment if you plan to work on it labels Jun 21, 2019
@dnkoutso
Copy link
Contributor

Marking as an enhancement

@facundor
Copy link
Author

Hi D. Thanks for response!

Yes, we are using test specs. The podspec structure we are using in our libs are like this:

Pod::Spec.new do |s|

# 1
s.platform = :ios
s.ios.deployment_target = '10.0'
s.name = "Core"
s.summary = "Core module."
s.requires_arc = true
s.static_framework = true

# 2 
s.version = "0.14.0-beta"

# 3
s.license = { :type => "MIT", :file => "LICENSE" }

# 4 - Replace with your name and e-mail address
s.author = { "Facundo Rodriguez" => "facundo.rodriguez@fluxit.com.ar" }

# 5 - Replace this URL with your own GitHub page's URL (from the address bar)
s.homepage = "https://abc/core"

# 6 - Replace this URL with your own Git URL
s.source = { :git => "git@abc/ios/core.git",
:tag => "#{s.version}" }

# 7
s.framework = "UIKit"
s.dependency 'Alamofire', '4.8.2'

# Auth0
s.dependency 'Auth0', '1.15'
s.dependency 'JWTDecode', '2.3.0'

# Google
s.dependency 'Firebase', '6.2.0'
s.dependency 'Firebase/Core', '6.2.0'
s.dependency 'Firebase/MLVision', '6.2.0'
s.dependency 'Firebase/MLVisionLabelModel', '6.2.0' 
s.dependency 'Firebase/MLVisionBarcodeModel', '6.2.0'
s.dependency 'Firebase/Messaging', '6.2.0'
s.dependency 'GoogleUtilities', '6.2.0'

s.dependency 'Crashlytics', '3.13.1'
s.dependency 'Fabric', '1.10.1'
s.dependency 'GoogleTagManager', '7.1.2'

# Split.io - Cutpoint
s.dependency 'Split', '2.3.0'

# Manejo de errores
s.dependency 'ReachabilitySwift', '4.3.1'

# Notificaciones push
s.dependency 'AWSCore', '2.9.9'

# 8
s.source_files = "Core/**/*.{swift}"

# 9
#s.resources = "Core/**/*.{storyboard}"

# Test configuration
**s.test_spec 'Tests' do |test_spec|
test_spec.dependency 'Mockingjay', '2.0.1'
test_spec.framework = 'XCTest'
test_spec.source_files = 'Tests/**/*.{h,m,swift,plist}'
end**

# 10
s.swift_version = "4.2"

end

In the Tests folder we put all test clasess with XCTest and Mockinjay code. We run testcases allways for CI / CD with pod lib lint and pod repo push over Bitrise. But for code quality and CI, the code coverage and tests statistics are very important.
We are using Sonarqube wifth Sonar Swift
https://docs.sonarqube.org/display/PLUG/SonarSwift. There is a way to upload the coverage generated for an a Swift App, executing a scripts series. https://docs.sonarqube.org/display/PLUG/Swift+Coverage+Results+Import but not work with cocoapod libs.

If an enhacement is posible, we will very glad!

Thanks again! We are in touch

Cheers

@dnkoutso
Copy link
Contributor

Yes this will need to be an enhancement in order to extend scheme DSL to support setting code coverage flag to true

@facundor
Copy link
Author

Great!

¿Do you think this enhancement will be choiced for implementation? ¿When you think this enhancement will be ready D.?

Thanks a lot!

@dnkoutso
Copy link
Contributor

The fastest way to implement it is to attempt to do it! I cannot guarantee personally any specific time this can be released.

@dnkoutso dnkoutso modified the milestones: 1.8.0, 1.9.0 Aug 8, 2019
@dnkoutso
Copy link
Contributor
dnkoutso commented Aug 8, 2019

Marking for 1.9.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
d2:moderate A moderately-difficult ticket that may require a bit of knowledge about the codebase t1:enhancement Enhancements that have not been picked up yet. Please comment if you plan to work on it t4:question This is a question to the maintainers. This could lead into closing the issue or into an enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0