"xcrun xcresulttool get --format json --path" deprecated - what's the alternative?

Hi,

I'm using the following command to extract information about the code coverage:

xcrun xcresulttool get --format json --path /some/path/to/xcresult             

However, since Xcode 16 I get:

Error: This command is deprecated and will be removed in a future release, --legacy flag is required to use it.

But this message doesn't tell us what's the alternative to get the same result. Or are you just getting rid of useful functionality and there is no alternative?

Answered by DTS Engineer in 804207022

to get the same result.

@maxik

To view the format, run the following command in Terminal: xcrun xcresulttool help get test-results summary

% xcrun xcresulttool help get test-results summary
OVERVIEW: Get test report summary.


Command output structure (JSON Schema): 
{
    "schemas": {
        "Summary": {
            "type": "object",
            "properties": {
                "title": {
                    "type": "string"
                },
                "startTime": {
                    "type": "number",
                    "format": "double",
                    "description": "Date as a UNIX timestamp (seconds since midnight UTC on January 1, 1970)"
                },
                "finishTime": {
                    "type": "number",
                    "format": "double",
                    "description": "Date as a UNIX timestamp (seconds since midnight UTC on January 1, 1970)"
                },
                "environmentDescription": {
                    "type": "string",
                    "description": "Description of the Test Plan, OS, and environment that was used during testing"
                },
                "topInsights": {
                    "type": "array",
                    "items": {
                        "$ref": "#/schemas/InsightSummary"
                    }
                },
                "result": {
                    "$ref": "#/schemas/TestResult"
                },
                "totalTestCount": {
                    "type": "integer"
                },
                "passedTests": {
                    "type": "integer"
                },
                "failedTests": {
                    "type": "integer"
                },
                "skippedTests": {
                    "type": "integer"
                },
                "expectedFailures": {
                    "type": "integer"
                },
                "statistics": {
                    "type": "array",
                    "items": {
                        "$ref": "#/schemas/Statistic"
                    }
                },
                "devicesAndConfigurations": {
                    "$ref": "#/schemas/DeviceAndConfigurationSummary"
                },
                "testFailures": {
                    "$ref": "#/schemas/TestFailure"
                }
            },
            "required": [
                "title",
                "environmentDescription",
                "topInsights",
                "result",
                "totalTestCount",
                "passedTests",
                "failedTests",
                "skippedTests",
                "expectedFailures",
                "statistics",
                "devicesAndConfigurations",
                "testFailures"
            ],
        },
        "InsightSummary": {
            "type": "object",
            "properties": {
                "impact": {
                    "type": "string"
                },
                "category": {
                    "type" "string"
                },
                "text": {
                    "type" "string"
                }
            },
            "required": [
                "impact",
                "category",
                "text"
            ]
        },
        "TestResult": {
            "type": "string",
            "enum": [
                "Passed",
                "Failed",
                "Skipped",
                "Expected Failure",
                "unknown"
            ]
        },
        "Statistic": {
            "type": "object",
            "properties": {
                "title": {
                    "type": "string"
                },
                "subtitle": {
                    "type": "string"
                }
            },
            "required": [
                "title",
                "subtitle"
            ]
        },
        "DeviceAndConfigurationSummary": {
            "type": "object",
            "properties": {
                "device": {
                    "$ref": "#/schemas/Device"
                },
                "testPlanConfiguration": {
                    "$ref": "#/schemas/Configuration"
                },
                "passedTests": {
                    "type": "integer"
                },
                "failedTests": {
                    "type": "integer"
                },
                "skippedTests": {
                    "type": "integer"
                },
                "expectedFailures": {
                    "type": "integer"
                }
            },
            "required": [
                "device",
                "testPlanConfiguration",
                "passedTests",
                "failedTests",
                "skippedTests",
                "expectedFailures"
            ]
        },
        "Device": {
            "type": "object",
            "properties": {
                "deviceId": {
                    "type": "string"
                },
                "deviceName": {
                    "type": "string"
                },
                "architecture": {
                    "type": "string"
                },
                "modelName": {
                    "type": "string"
                },
                "platform": {
                    "type": "string"
                },
                "osVersion": {
                    "type": "string"
                }
            },
            "required": [
                "deviceName",
                "architecture",
                "modelName",
                "osVersion"
            ]
        },
        "Configuration": {
            "type": "object",
            "properties": {
                "configurationId": {
                    "type": "string"
                },
                "configurationName": {
                    "type": "string"
                }
            },
            "required": [
                "configurationId",
                "configurationName"
            ]
        },
        "TestFailure": {
            "type": "object",
            "properties": {
                "testName": {
                    "type": "string"
                },
                "targetName": {
                    "type": "string"
                },
                "failureText": {
                    "type": "string"
                },
                "testIdentifier": {
                    "type": "integer",
                    "format": "int64"
                }
            },
            "required": [
                "testName",
                "targetName",
                "failureText",
                "testIdentifier"
            ]
        }
    }
}

USAGE: xcresulttool get test-results summary --path <path> [--compact]

OPTIONS:
  --path <path>           The result bundle path.
  --compact               Output JSON in a compact format.
  --version               Show the version.
  -h, --help              Show help information.

to get the same result.

@maxik

To view the format, run the following command in Terminal: xcrun xcresulttool help get test-results summary

% xcrun xcresulttool help get test-results summary
OVERVIEW: Get test report summary.


Command output structure (JSON Schema): 
{
    "schemas": {
        "Summary": {
            "type": "object",
            "properties": {
                "title": {
                    "type": "string"
                },
                "startTime": {
                    "type": "number",
                    "format": "double",
                    "description": "Date as a UNIX timestamp (seconds since midnight UTC on January 1, 1970)"
                },
                "finishTime": {
                    "type": "number",
                    "format": "double",
                    "description": "Date as a UNIX timestamp (seconds since midnight UTC on January 1, 1970)"
                },
                "environmentDescription": {
                    "type": "string",
                    "description": "Description of the Test Plan, OS, and environment that was used during testing"
                },
                "topInsights": {
                    "type": "array",
                    "items": {
                        "$ref": "#/schemas/InsightSummary"
                    }
                },
                "result": {
                    "$ref": "#/schemas/TestResult"
                },
                "totalTestCount": {
                    "type": "integer"
                },
                "passedTests": {
                    "type": "integer"
                },
                "failedTests": {
                    "type": "integer"
                },
                "skippedTests": {
                    "type": "integer"
                },
                "expectedFailures": {
                    "type": "integer"
                },
                "statistics": {
                    "type": "array",
                    "items": {
                        "$ref": "#/schemas/Statistic"
                    }
                },
                "devicesAndConfigurations": {
                    "$ref": "#/schemas/DeviceAndConfigurationSummary"
                },
                "testFailures": {
                    "$ref": "#/schemas/TestFailure"
                }
            },
            "required": [
                "title",
                "environmentDescription",
                "topInsights",
                "result",
                "totalTestCount",
                "passedTests",
                "failedTests",
                "skippedTests",
                "expectedFailures",
                "statistics",
                "devicesAndConfigurations",
                "testFailures"
            ],
        },
        "InsightSummary": {
            "type": "object",
            "properties": {
                "impact": {
                    "type": "string"
                },
                "category": {
                    "type" "string"
                },
                "text": {
                    "type" "string"
                }
            },
            "required": [
                "impact",
                "category",
                "text"
            ]
        },
        "TestResult": {
            "type": "string",
            "enum": [
                "Passed",
                "Failed",
                "Skipped",
                "Expected Failure",
                "unknown"
            ]
        },
        "Statistic": {
            "type": "object",
            "properties": {
                "title": {
                    "type": "string"
                },
                "subtitle": {
                    "type": "string"
                }
            },
            "required": [
                "title",
                "subtitle"
            ]
        },
        "DeviceAndConfigurationSummary": {
            "type": "object",
            "properties": {
                "device": {
                    "$ref": "#/schemas/Device"
                },
                "testPlanConfiguration": {
                    "$ref": "#/schemas/Configuration"
                },
                "passedTests": {
                    "type": "integer"
                },
                "failedTests": {
                    "type": "integer"
                },
                "skippedTests": {
                    "type": "integer"
                },
                "expectedFailures": {
                    "type": "integer"
                }
            },
            "required": [
                "device",
                "testPlanConfiguration",
                "passedTests",
                "failedTests",
                "skippedTests",
                "expectedFailures"
            ]
        },
        "Device": {
            "type": "object",
            "properties": {
                "deviceId": {
                    "type": "string"
                },
                "deviceName": {
                    "type": "string"
                },
                "architecture": {
                    "type": "string"
                },
                "modelName": {
                    "type": "string"
                },
                "platform": {
                    "type": "string"
                },
                "osVersion": {
                    "type": "string"
                }
            },
            "required": [
                "deviceName",
                "architecture",
                "modelName",
                "osVersion"
            ]
        },
        "Configuration": {
            "type": "object",
            "properties": {
                "configurationId": {
                    "type": "string"
                },
                "configurationName": {
                    "type": "string"
                }
            },
            "required": [
                "configurationId",
                "configurationName"
            ]
        },
        "TestFailure": {
            "type": "object",
            "properties": {
                "testName": {
                    "type": "string"
                },
                "targetName": {
                    "type": "string"
                },
                "failureText": {
                    "type": "string"
                },
                "testIdentifier": {
                    "type": "integer",
                    "format": "int64"
                }
            },
            "required": [
                "testName",
                "targetName",
                "failureText",
                "testIdentifier"
            ]
        }
    }
}

USAGE: xcresulttool get test-results summary --path <path> [--compact]

OPTIONS:
  --path <path>           The result bundle path.
  --compact               Output JSON in a compact format.
  --version               Show the version.
  -h, --help              Show help information.

@DTS Engineer Actually, it's not an alternative to me. The command you mentioned doesn't provide the archive id which I'm later using to export xccovarchive and retrieve code coverage for a file.

So first I export archive (using the id retrieved from the first command):


xcrun xcresulttool export --type directory --id <ArchiveRef> --path <xcresult path> --output-path <path>

which is also deprecated. And then I read the code coverage for a specific file with:


xcrun xccov view --file <file> <xccovarchive path>

So how do you achieve the same without using deprecated commands?

Is there any alternative or is that functionality abandoned? How can I get code coverage for a specific file?

I figured it out. It turns out that I can directly use xcrun xccov on xctestresult file.

@maxik - can you provide how did you achieved working solution you mentioned? please :)

"xcrun xcresulttool get --format json --path" deprecated - what's the alternative?
 
 
Q