Skip to content

Commit 0d0a135

Browse files
Merge pull request #792 from salesforcecli/er/logic-get-test-command
W-19262690: add new logic get test command
2 parents e11cce0 + 05fb0c3 commit 0d0a135

File tree

16 files changed

+4398
-3100
lines changed

16 files changed

+4398
-3100
lines changed

command-snapshot.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,33 @@
9696
"flagChars": ["c", "d", "o", "s"],
9797
"flags": ["api-version", "color", "debug-level", "flags-dir", "loglevel", "skip-trace-flag", "target-org"],
9898
"plugin": "@salesforce/plugin-apex"
99+
},
100+
{
101+
"command": "logic:get:test",
102+
"flagAliases": [
103+
"apiversion",
104+
"codecoverage",
105+
"output-directory",
106+
"outputdir",
107+
"resultformat",
108+
"targetusername",
109+
"testrunid",
110+
"u"
111+
],
112+
"flagChars": ["c", "d", "i", "o", "r"],
113+
"flags": [
114+
"api-version",
115+
"code-coverage",
116+
"concise",
117+
"detailed-coverage",
118+
"flags-dir",
119+
"json",
120+
"loglevel",
121+
"output-dir",
122+
"result-format",
123+
"target-org",
124+
"test-run-id"
125+
],
126+
"plugin": "@salesforce/plugin-apex"
99127
}
100128
]

messages/logicgettest.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# summary
2+
3+
Get the results of a test run.
4+
5+
# description
6+
7+
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.
8+
9+
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.
10+
11+
# examples
12+
13+
- Get the results for a specific test run ID in the default human-readable format; uses your default org:
14+
15+
<%= config.bin %> <%= command.id %> --test-run-id <test run id>
16+
17+
- 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":
18+
19+
<%= config.bin %> <%= command.id %> --test-run-id <test run id> --result-format junit --target-org my-scratch
20+
21+
# flags.test-run-id.summary
22+
23+
ID of the test run.
24+
25+
# flags.output-dir.summary
26+
27+
Directory in which to store test result files.
28+
29+
# flags.concise.summary
30+
31+
Display only failed test results; works with human-readable output only.
32+
33+
# apexLibErr
34+
35+
Unknown error in Apex Library: %s
36+
37+
# flags.detailed-coverage.summary
38+
39+
Display detailed code coverage per test.

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Salesforce",
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
8-
"@salesforce/apex-node": "^8.1.27",
8+
"@salesforce/apex-node": "^8.3.1",
99
"@salesforce/core": "^8.10.1",
1010
"@salesforce/kit": "^3.2.3",
1111
"@salesforce/sf-plugins-core": "^12.2.1",
@@ -66,6 +66,14 @@
6666
"description": "Tail debug logs."
6767
}
6868
}
69+
},
70+
"logic": {
71+
"description": "Use the logic commands to run Apex and Flow tests and view the test results.",
72+
"subtopics": {
73+
"get": {
74+
"description": "Get debug logs or test results."
75+
}
76+
}
6977
}
7078
},
7179
"devPlugins": [
@@ -205,7 +213,7 @@
205213
"output": []
206214
},
207215
"link-check": {
208-
"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",
216+
"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",
209217
"files": [
210218
"./*.md",
211219
"./!(CHANGELOG).md",

schemas/logic-get-test.json

Lines changed: 289 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,289 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$ref": "#/definitions/RunResult",
4+
"definitions": {
5+
"RunResult": {
6+
"type": "object",
7+
"properties": {
8+
"summary": {
9+
"type": "object",
10+
"properties": {
11+
"outcome": {
12+
"$ref": "#/definitions/ApexTestRunResultStatus"
13+
},
14+
"testsRan": {
15+
"type": "number"
16+
},
17+
"passing": {
18+
"type": "number"
19+
},
20+
"failing": {
21+
"type": "number"
22+
},
23+
"skipped": {
24+
"type": "number"
25+
},
26+
"passRate": {
27+
"type": "string"
28+
},
29+
"failRate": {
30+
"type": "string"
31+
},
32+
"testStartTime": {
33+
"type": "string"
34+
},
35+
"testExecutionTime": {
36+
"type": "string"
37+
},
38+
"testTotalTime": {
39+
"type": "string"
40+
},
41+
"commandTime": {
42+
"type": "string"
43+
},
44+
"hostname": {
45+
"type": "string"
46+
},
47+
"orgId": {
48+
"type": "string"
49+
},
50+
"username": {
51+
"type": "string"
52+
},
53+
"testRunId": {
54+
"type": "string"
55+
},
56+
"userId": {
57+
"type": "string"
58+
},
59+
"orgWideCoverage": {
60+
"type": "string"
61+
},
62+
"testRunCoverage": {
63+
"type": "string"
64+
}
65+
},
66+
"required": [
67+
"outcome",
68+
"testsRan",
69+
"passing",
70+
"failing",
71+
"skipped",
72+
"passRate",
73+
"failRate",
74+
"testStartTime",
75+
"testExecutionTime",
76+
"testTotalTime",
77+
"commandTime",
78+
"hostname",
79+
"orgId",
80+
"username",
81+
"testRunId",
82+
"userId"
83+
],
84+
"additionalProperties": false
85+
},
86+
"tests": {
87+
"type": "array",
88+
"items": {
89+
"type": "object",
90+
"properties": {
91+
"Id": {
92+
"type": "string"
93+
},
94+
"QueueItemId": {
95+
"type": "string"
96+
},
97+
"StackTrace": {
98+
"type": "string"
99+
},
100+
"Message": {
101+
"type": "string"
102+
},
103+
"AsyncApexJobId": {
104+
"type": "string"
105+
},
106+
"MethodName": {
107+
"type": "string"
108+
},
109+
"Outcome": {
110+
"$ref": "#/definitions/ApexTestResultOutcome"
111+
},
112+
"ApexClass": {
113+
"type": "object",
114+
"properties": {
115+
"Id": {
116+
"type": "string"
117+
},
118+
"Name": {
119+
"type": "string"
120+
},
121+
"NamespacePrefix": {
122+
"type": "string"
123+
}
124+
},
125+
"required": ["Id", "Name", "NamespacePrefix"],
126+
"additionalProperties": false
127+
},
128+
"RunTime": {
129+
"type": "number"
130+
},
131+
"FullName": {
132+
"type": "string"
133+
}
134+
},
135+
"required": [
136+
"Id",
137+
"QueueItemId",
138+
"StackTrace",
139+
"Message",
140+
"AsyncApexJobId",
141+
"MethodName",
142+
"Outcome",
143+
"ApexClass",
144+
"RunTime",
145+
"FullName"
146+
],
147+
"additionalProperties": false
148+
}
149+
},
150+
"coverage": {
151+
"type": "object",
152+
"properties": {
153+
"coverage": {
154+
"type": "array",
155+
"items": {
156+
"type": "object",
157+
"properties": {
158+
"id": {
159+
"type": "string"
160+
},
161+
"name": {
162+
"type": "string"
163+
},
164+
"totalLines": {
165+
"type": "number"
166+
},
167+
"lines": {
168+
"type": "object",
169+
"additionalProperties": {
170+
"type": "number"
171+
}
172+
},
173+
"totalCovered": {
174+
"type": "number"
175+
},
176+
"coveredPercent": {
177+
"type": "number"
178+
}
179+
},
180+
"required": ["id", "name", "totalLines", "lines", "totalCovered", "coveredPercent"],
181+
"additionalProperties": false
182+
}
183+
},
184+
"records": {
185+
"type": "array",
186+
"items": {
187+
"type": "object",
188+
"properties": {
189+
"ApexTestClass": {
190+
"type": "object",
191+
"properties": {
192+
"Id": {
193+
"type": "string"
194+
},
195+
"Name": {
196+
"type": "string"
197+
}
198+
},
199+
"required": ["Id", "Name"],
200+
"additionalProperties": false
201+
},
202+
"Coverage": {
203+
"type": "object",
204+
"properties": {
205+
"coveredLines": {
206+
"type": "array",
207+
"items": {
208+
"type": "number"
209+
}
210+
},
211+
"uncoveredLines": {
212+
"type": "array",
213+
"items": {
214+
"type": "number"
215+
}
216+
}
217+
},
218+
"required": ["coveredLines", "uncoveredLines"],
219+
"additionalProperties": false
220+
},
221+
"TestMethodName": {
222+
"type": "string"
223+
},
224+
"NumLinesCovered": {
225+
"type": "number"
226+
},
227+
"ApexClassOrTrigger": {
228+
"type": "object",
229+
"properties": {
230+
"Id": {
231+
"type": "string"
232+
},
233+
"Name": {
234+
"type": "string"
235+
}
236+
},
237+
"required": ["Id", "Name"],
238+
"additionalProperties": false
239+
},
240+
"NumLinesUncovered": {
241+
"type": "number"
242+
}
243+
},
244+
"required": [
245+
"ApexTestClass",
246+
"TestMethodName",
247+
"NumLinesCovered",
248+
"ApexClassOrTrigger",
249+
"NumLinesUncovered"
250+
],
251+
"additionalProperties": false
252+
}
253+
},
254+
"summary": {
255+
"type": "object",
256+
"properties": {
257+
"totalLines": {
258+
"type": "number"
259+
},
260+
"coveredLines": {
261+
"type": "number"
262+
},
263+
"testRunCoverage": {
264+
"type": "string"
265+
},
266+
"orgWideCoverage": {
267+
"type": "string"
268+
}
269+
},
270+
"additionalProperties": false
271+
}
272+
},
273+
"required": ["coverage", "records", "summary"],
274+
"additionalProperties": false
275+
}
276+
},
277+
"required": ["summary", "tests"],
278+
"additionalProperties": false
279+
},
280+
"ApexTestRunResultStatus": {
281+
"type": "string",
282+
"enum": ["Queued", "Processing", "Aborted", "Passed", "Failed", "Completed", "Skipped"]
283+
},
284+
"ApexTestResultOutcome": {
285+
"type": "string",
286+
"enum": ["Pass", "Fail", "CompileFail", "Skip"]
287+
}
288+
}
289+
}

0 commit comments

Comments
 (0)