Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,33 @@
"flagChars": ["c", "d", "o", "s"],
"flags": ["api-version", "color", "debug-level", "flags-dir", "loglevel", "skip-trace-flag", "target-org"],
"plugin": "@salesforce/plugin-apex"
},
{
"command": "logic:get:test",
"flagAliases": [
"apiversion",
"codecoverage",
"output-directory",
"outputdir",
"resultformat",
"targetusername",
"testrunid",
"u"
],
"flagChars": ["c", "d", "i", "o", "r"],
"flags": [
"api-version",
"code-coverage",
"concise",
"detailed-coverage",
"flags-dir",
"json",
"loglevel",
"output-dir",
"result-format",
"target-org",
"test-run-id"
],
"plugin": "@salesforce/plugin-apex"
}
]
39 changes: 39 additions & 0 deletions messages/logicgettest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# summary

Get the results of a test run.

# description

When you run 'sf logic run test' to test Apex classes and Flows asynchronously, it returns a test run ID. Use that ID with this command to see the results.

To see code coverage results, use the --code-coverage flag with --result-format. The output displays a high-level summary of the test run and the code coverage values for classes in your org. If you specify human-readable result format, use the --detailed-coverage flag to see detailed coverage results for each test method run.

# examples

- Get the results for a specific test run ID in the default human-readable format; uses your default org:

<%= config.bin %> <%= command.id %> --test-run-id <test run id>

- Get the results for a specific test run ID, format them as JUnit, and save them to the "test-results/junit" directory; uses the org with alias "my-scratch":

<%= config.bin %> <%= command.id %> --test-run-id <test run id> --result-format junit --target-org my-scratch

# flags.test-run-id.summary

ID of the test run.

# flags.output-dir.summary

Directory in which to store test result files.

# flags.concise.summary

Display only failed test results; works with human-readable output only.

# apexLibErr

Unknown error in Apex Library: %s

# flags.detailed-coverage.summary

Display detailed code coverage per test.
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Salesforce",
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@salesforce/apex-node": "^8.1.27",
"@salesforce/apex-node": "^8.3.1",
"@salesforce/core": "^8.10.1",
"@salesforce/kit": "^3.2.3",
"@salesforce/sf-plugins-core": "^12.2.1",
Expand Down Expand Up @@ -66,6 +66,14 @@
"description": "Tail debug logs."
}
}
},
"logic": {
"description": "Use the logic commands to run Apex and Flow tests and view the test results.",
"subtopics": {
"get": {
"description": "Get debug logs or test results."
}
}
}
},
"devPlugins": [
Expand Down Expand Up @@ -205,7 +213,7 @@
"output": []
},
"link-check": {
"command": "node -e \"process.exit(process.env.CI ? 0 : 1)\" || linkinator \"**/*.md\" --skip \"CHANGELOG.md|node_modules|test/|confluence.internal.salesforce.com|my.salesforce.com|%s\" --markdown --retry --directory-listing --verbosity error",
"command": "node -e \"process.exit(process.env.CI ? 0 : 1)\" || linkinator \"**/*.md\" --skip \"CHANGELOG.md|node_modules|test/|confluence.internal.salesforce.com|my.salesforce.com|localhost|%s\" --markdown --retry --directory-listing --verbosity error",
"files": [
"./*.md",
"./!(CHANGELOG).md",
Expand Down
289 changes: 289 additions & 0 deletions schemas/logic-get-test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/RunResult",
"definitions": {
"RunResult": {
"type": "object",
"properties": {
"summary": {
"type": "object",
"properties": {
"outcome": {
"$ref": "#/definitions/ApexTestRunResultStatus"
},
"testsRan": {
"type": "number"
},
"passing": {
"type": "number"
},
"failing": {
"type": "number"
},
"skipped": {
"type": "number"
},
"passRate": {
"type": "string"
},
"failRate": {
"type": "string"
},
"testStartTime": {
"type": "string"
},
"testExecutionTime": {
"type": "string"
},
"testTotalTime": {
"type": "string"
},
"commandTime": {
"type": "string"
},
"hostname": {
"type": "string"
},
"orgId": {
"type": "string"
},
"username": {
"type": "string"
},
"testRunId": {
"type": "string"
},
"userId": {
"type": "string"
},
"orgWideCoverage": {
"type": "string"
},
"testRunCoverage": {
"type": "string"
}
},
"required": [
"outcome",
"testsRan",
"passing",
"failing",
"skipped",
"passRate",
"failRate",
"testStartTime",
"testExecutionTime",
"testTotalTime",
"commandTime",
"hostname",
"orgId",
"username",
"testRunId",
"userId"
],
"additionalProperties": false
},
"tests": {
"type": "array",
"items": {
"type": "object",
"properties": {
"Id": {
"type": "string"
},
"QueueItemId": {
"type": "string"
},
"StackTrace": {
"type": "string"
},
"Message": {
"type": "string"
},
"AsyncApexJobId": {
"type": "string"
},
"MethodName": {
"type": "string"
},
"Outcome": {
"$ref": "#/definitions/ApexTestResultOutcome"
},
"ApexClass": {
"type": "object",
"properties": {
"Id": {
"type": "string"
},
"Name": {
"type": "string"
},
"NamespacePrefix": {
"type": "string"
}
},
"required": ["Id", "Name", "NamespacePrefix"],
"additionalProperties": false
},
"RunTime": {
"type": "number"
},
"FullName": {
"type": "string"
}
},
"required": [
"Id",
"QueueItemId",
"StackTrace",
"Message",
"AsyncApexJobId",
"MethodName",
"Outcome",
"ApexClass",
"RunTime",
"FullName"
],
"additionalProperties": false
}
},
"coverage": {
"type": "object",
"properties": {
"coverage": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"totalLines": {
"type": "number"
},
"lines": {
"type": "object",
"additionalProperties": {
"type": "number"
}
},
"totalCovered": {
"type": "number"
},
"coveredPercent": {
"type": "number"
}
},
"required": ["id", "name", "totalLines", "lines", "totalCovered", "coveredPercent"],
"additionalProperties": false
}
},
"records": {
"type": "array",
"items": {
"type": "object",
"properties": {
"ApexTestClass": {
"type": "object",
"properties": {
"Id": {
"type": "string"
},
"Name": {
"type": "string"
}
},
"required": ["Id", "Name"],
"additionalProperties": false
},
"Coverage": {
"type": "object",
"properties": {
"coveredLines": {
"type": "array",
"items": {
"type": "number"
}
},
"uncoveredLines": {
"type": "array",
"items": {
"type": "number"
}
}
},
"required": ["coveredLines", "uncoveredLines"],
"additionalProperties": false
},
"TestMethodName": {
"type": "string"
},
"NumLinesCovered": {
"type": "number"
},
"ApexClassOrTrigger": {
"type": "object",
"properties": {
"Id": {
"type": "string"
},
"Name": {
"type": "string"
}
},
"required": ["Id", "Name"],
"additionalProperties": false
},
"NumLinesUncovered": {
"type": "number"
}
},
"required": [
"ApexTestClass",
"TestMethodName",
"NumLinesCovered",
"ApexClassOrTrigger",
"NumLinesUncovered"
],
"additionalProperties": false
}
},
"summary": {
"type": "object",
"properties": {
"totalLines": {
"type": "number"
},
"coveredLines": {
"type": "number"
},
"testRunCoverage": {
"type": "string"
},
"orgWideCoverage": {
"type": "string"
}
},
"additionalProperties": false
}
},
"required": ["coverage", "records", "summary"],
"additionalProperties": false
}
},
"required": ["summary", "tests"],
"additionalProperties": false
},
"ApexTestRunResultStatus": {
"type": "string",
"enum": ["Queued", "Processing", "Aborted", "Passed", "Failed", "Completed", "Skipped"]
},
"ApexTestResultOutcome": {
"type": "string",
"enum": ["Pass", "Fail", "CompileFail", "Skip"]
}
}
}
Loading
Loading