3 Replies
      Latest reply on Nov 19, 2019 2:47 AM by Divya.v
      marcin_ Level 1 Level 1 (0 points)

        In Xcode 10 I was able to get detailed coverage data by using `xccov` tool by calling:
        -  `xcrun xccov view --file-list` - to get all the paths to sources files
        -  `xcrun xccov view --file <path_to_source_file> <path_to_xcresult>` - to get line coverage data for the given file.

        Looks like in Xcode 11 we should be able to get the same level of details by using `xcrun xccov view --report --files-for-target` and  `xcrun xccov view --report --functions-for-file` but it does not work that way.

        First issue I expirienced is mangled swift method names. When the `xcresult` file is created while running xcodebuild, the functions names are mangled.

        Name                                                                                                                                                                            Coverage
        ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------
        CodeCoverageDemo.app                                                                                                                                                            47.46% (28/59)
            /Users/miwanicki1/TestProjects/CodeCoverageDemo/CodeCoverageDemo/SceneDelegate.swift                                                                                      34.48% (10/29)
                $s16CodeCoverageDemo13SceneDelegateC5scene_13willConnectTo7optionsySo7UISceneC_So0K7SessionCSo0K17ConnectionOptionsCtF                                                  100.00% (6/6)
                $s16CodeCoverageDemo13SceneDelegateC18sceneDidDisconnectyySo7UISceneCF                                                                                             0.00% (0/6

        Surprisingly, the issue does not occure when the tests are run in the Xcode.
        Second issue is that when using the new xccov with `--report`, I do not get the line-level coverage for an idividual source file. `--files-for-target` seems to return only an overview of the function coverage without enumerating the lines and branches.

         

         

        2019-10-15 11:55:38.950 xccov[19041:170343] Requested but did not find extension point with identifier Xcode.IDEFoundation.IDEResultKitSerializationConverter
        /Users/miwanicki1/TestProjects/CodeCoverageDemo/CodeCoverageDemo/MathDemo.swift:
        ID Name                                            Range   Coverage
        -- ----------------------------------------------- ------- ------------
        0  $s16CodeCoverageDemo04MathC0C3addyS2i_SitF      {5, 6}  83.33% (5/6)
        1  $s16CodeCoverageDemo04MathC0C5minusyS2i_SitF    {12, 3} 0.00% (0/3)
        2  $s16CodeCoverageDemo04MathC0C8multipleyS2i_SitF {16, 3} 0.00% (0/3)



        Anyone had similar problems? What's the recommended way to get the line-level parsable coverage report similar to the format below where 1 means the lines was executed once, 0 the line wasn't executed.

        1|    func add(_ a: Int, _ b: Int) -> Int {
        1|        if a < 10 {
        1|            return a + b
        1|        }
        0|        if a == 20 {
        0|            return 1
        0|        }
        0|        if a == 30 {
        0|           return 2
        0|        }
        0|
        0|        return a + 2 * b
        1|    }
        • Re: Xcode 11.1 code coverage data from xccov
          davidtrax Level 1 Level 1 (0 points)

          I'm having the same problem with the report not being symbolicated.  I'll let you know if I find a solution.

            • Re: Xcode 11.1 code coverage data from xccov
              marcin_ Level 1 Level 1 (0 points)

              Hi @davidtrax,

              Latest beta Version 11.2 beta 2 (11B44) seems to resolve the issues (both symbolication and line-level report).

              Line-level coverage can be pulled via:
              xccov view --archive [--file-list | --file <path>] result_bundle.xcresult

              Everything seems to work fine, at least in my small test project.














            • Re: Xcode 11.1 code coverage data from xccov
              Divya.v Level 1 Level 1 (0 points)

              Getting same kind of issue for code coverage report.Please provide the solution.Using Xcode 11.2.1.

               

              xccov[4508:118225] Requested but did not find extension point with identifier Xcode.IDEFoundation.IDEResultKitSerializationConverter

              Error: Error Domain=XCCovErrorDomain Code=0 "Failed to load coverage report for scheme action 'Testing with scheme' in result bundle" UserInfo={NSLocalizedDescription=Failed to load coverage report for scheme action 'Testing with scheme' in result bundle, NSUnderlyingError=0x7fd4f401f3f0 {Error Domain=NSCocoaErrorDomain Code=260 "The file “action.xccovreport” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/tmp/action.xccovreport, NSUnderlyingError=0x7fd4f4022980 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}}}