Skip to content

Commit a5cb4b2

Browse files
committed
Merge remote-tracking branch 'origin/main' into sm/linter-undefined
2 parents 4bccdaa + 06bfade commit a5cb4b2

File tree

15 files changed

+1943
-2749
lines changed

15 files changed

+1943
-2749
lines changed

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
## [3.2.5](https://github.com/salesforcecli/plugin-apex/compare/3.2.4...3.2.5) (2024-07-14)
2+
3+
### Bug Fixes
4+
5+
- **deps:** bump @salesforce/sf-plugins-core from 11.1.2 to 11.1.6 ([0422b2c](https://github.com/salesforcecli/plugin-apex/commit/0422b2cac21f00695c376535ac4b24801afd91b7))
6+
7+
## [3.2.4](https://github.com/salesforcecli/plugin-apex/compare/3.2.3...3.2.4) (2024-07-07)
8+
9+
### Bug Fixes
10+
11+
- **deps:** bump @salesforce/apex-node from 7.0.3 to 7.0.4 ([e885af8](https://github.com/salesforcecli/plugin-apex/commit/e885af885e18ed75cadf556767a3ac494de7520f))
12+
13+
## [3.2.3](https://github.com/salesforcecli/plugin-apex/compare/3.2.2...3.2.3) (2024-07-02)
14+
15+
### Bug Fixes
16+
17+
- **deps:** bump apex library ([#513](https://github.com/salesforcecli/plugin-apex/issues/513)) ([edd63e8](https://github.com/salesforcecli/plugin-apex/commit/edd63e8d629fc1976358da58e7cf75006d883159))
18+
19+
## [3.2.2](https://github.com/salesforcecli/plugin-apex/compare/3.2.1...3.2.2) (2024-06-30)
20+
21+
### Bug Fixes
22+
23+
- **deps:** bump @oclif/core from 4.0.6 to 4.0.7 ([152b032](https://github.com/salesforcecli/plugin-apex/commit/152b03235a83dc7e1d8728afc8a8c4d6f213c51d))
24+
25+
## [3.2.1](https://github.com/salesforcecli/plugin-apex/compare/3.2.0...3.2.1) (2024-06-27)
26+
27+
### Bug Fixes
28+
29+
- added examples to apex run and apex get ([fb56783](https://github.com/salesforcecli/plugin-apex/commit/fb5678372f63008b2089799f30ac2c1f9158c802))
30+
131
# [3.2.0](https://github.com/salesforcecli/plugin-apex/compare/3.1.22...3.2.0) (2024-06-18)
232

333
### Features

README.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ FLAG DESCRIPTIONS
148148
directory.
149149
```
150150

151-
_See code: [src/commands/apex/get/log.ts](https://github.com/salesforcecli/plugin-apex/blob/3.2.0/src/commands/apex/get/log.ts)_
151+
_See code: [src/commands/apex/get/log.ts](https://github.com/salesforcecli/plugin-apex/blob/3.2.5/src/commands/apex/get/log.ts)_
152152

153153
## `sf apex get test`
154154

@@ -199,10 +199,10 @@ EXAMPLES
199199
default org):
200200
201201
$ sf apex get test --test-run-id <test run id> --code-coverage --output-dir <path to outputdir> --target-org \
202-
me@myorg',
202+
me@myorg'
203203
```
204204

205-
_See code: [src/commands/apex/get/test.ts](https://github.com/salesforcecli/plugin-apex/blob/3.2.0/src/commands/apex/get/test.ts)_
205+
_See code: [src/commands/apex/get/test.ts](https://github.com/salesforcecli/plugin-apex/blob/3.2.5/src/commands/apex/get/test.ts)_
206206

207207
## `sf apex list log`
208208

@@ -242,7 +242,7 @@ EXAMPLES
242242
$ sf apex list log --target-org me@my.org
243243
```
244244

245-
_See code: [src/commands/apex/list/log.ts](https://github.com/salesforcecli/plugin-apex/blob/3.2.0/src/commands/apex/list/log.ts)_
245+
_See code: [src/commands/apex/list/log.ts](https://github.com/salesforcecli/plugin-apex/blob/3.2.5/src/commands/apex/list/log.ts)_
246246

247247
## `sf apex run`
248248

@@ -289,7 +289,7 @@ EXAMPLES
289289
$ sf apex run
290290
```
291291

292-
_See code: [src/commands/apex/run.ts](https://github.com/salesforcecli/plugin-apex/blob/3.2.0/src/commands/apex/run.ts)_
292+
_See code: [src/commands/apex/run.ts](https://github.com/salesforcecli/plugin-apex/blob/3.2.5/src/commands/apex/run.ts)_
293293

294294
## `sf apex run test`
295295

@@ -369,14 +369,45 @@ EXAMPLES
369369
370370
$ sf apex run test --test-level RunLocalTests --output-dir <path to outputdir> --target-org me@my.org
371371
372+
Run all tests in the org asynchronously:
373+
374+
$ sf apex run test --target-org myscratch
375+
376+
Run all tests synchronously; the command waits to display the test results until all tests finish:
377+
378+
$ sf apex run test --synchronous
379+
380+
Run specific tests using the --test-level flag:
381+
382+
$ sf apex run test --test-level RunLocalTests
383+
384+
Run Apex tests on all the methods in the specified class; output results in Test Anything Protocol (TAP) format and
385+
request code coverage results:
386+
387+
$ sf apex run test --class-names TestA --class-names TestB --result-format tap --code-coverage
388+
389+
Run Apex tests on methods specified using the standard Class.method notation; if you specify a test class without a
390+
method, the command runs all methods in the class:
391+
392+
$ sf apex run test --tests TestA.excitingMethod --tests TestA.boringMethod --tests TestB
393+
394+
Run Apex tests on methods specified using the standard Class.method notation with a namespace:
395+
396+
$ sf apex run test --tests ns.TestA.excitingMethod --tests ns.TestA.boringMethod --tests ns.TestB
397+
372398
FLAG DESCRIPTIONS
373399
-l, --test-level=RunLocalTests|RunAllTestsInOrg|RunSpecifiedTests Level of tests to run; default is RunLocalTests.
374400
375401
Here's what the levels mean:
376402
377-
- RunSpecifiedTests — Only the tests that you specify are run.
378-
- RunLocalTests — All tests in your org are run, except the ones that originate from installed managed packages.
379-
- RunAllTestsInOrg — All tests are in your org and in installed managed packages are run
403+
- RunSpecifiedTests — Only the tests that you specify in the runTests option are run. Code coverage requirements
404+
differ from the default coverage requirements when using this test level. The executed tests must cover each class
405+
and trigger in the deployment package for a minimum of 75% code coverage. This coverage is computed for each class
406+
and triggers individually, and is different than the overall coverage percentage.
407+
- RunLocalTests — All local tests in your org, including tests that originate from no-namespaced unlocked packages,
408+
are run. The tests that originate from installed managed packages and namespaced unlocked packages aren't run. This
409+
test level is the default for production deployments that include Apex classes or triggers.
410+
- RunAllTestsInOrg — All tests are run. The tests include all tests in your org.
380411
381412
-n, --class-names=<value>... Apex test class names to run; default is all classes.
382413
@@ -399,7 +430,7 @@ FLAG DESCRIPTIONS
399430
--tests Test1 --tests Test2
400431
```
401432

402-
_See code: [src/commands/apex/run/test.ts](https://github.com/salesforcecli/plugin-apex/blob/3.2.0/src/commands/apex/run/test.ts)_
433+
_See code: [src/commands/apex/run/test.ts](https://github.com/salesforcecli/plugin-apex/blob/3.2.5/src/commands/apex/run/test.ts)_
403434

404435
## `sf apex tail log`
405436

@@ -442,6 +473,6 @@ EXAMPLES
442473
$ sf apex tail log --color --skip-trace-flag
443474
```
444475

445-
_See code: [src/commands/apex/tail/log.ts](https://github.com/salesforcecli/plugin-apex/blob/3.2.0/src/commands/apex/tail/log.ts)_
476+
_See code: [src/commands/apex/tail/log.ts](https://github.com/salesforcecli/plugin-apex/blob/3.2.5/src/commands/apex/tail/log.ts)_
446477

447478
<!-- commandsstop -->

messages/gettest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Provide a test run ID to display test results for an enqueued or completed async
2222

2323
- Specify a directory in which to save the test results from the org with the specified username (rather than your default org):
2424

25-
<%= config.bin %> <%= command.id %> --test-run-id <test run id> --code-coverage --output-dir <path to outputdir> --target-org me@myorg',
25+
<%= config.bin %> <%= command.id %> --test-run-id <test run id> --code-coverage --output-dir <path to outputdir> --target-org me@myorg'
2626

2727
# flags.test-run-id.summary
2828

messages/runtest.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,30 @@ NOTE: The testRunCoverage value (JSON and JUnit result formats) is a percentage
3434

3535
<%= config.bin %> <%= command.id %> --test-level RunLocalTests --output-dir <path to outputdir> --target-org me@my.org
3636

37+
- Run all tests in the org asynchronously:
38+
39+
<%= config.bin %> <%= command.id %> --target-org myscratch
40+
41+
- Run all tests synchronously; the command waits to display the test results until all tests finish:
42+
43+
<%= config.bin %> <%= command.id %> --synchronous
44+
45+
- Run specific tests using the --test-level flag:
46+
47+
<%= config.bin %> <%= command.id %> --test-level RunLocalTests
48+
49+
- Run Apex tests on all the methods in the specified class; output results in Test Anything Protocol (TAP) format and request code coverage results:
50+
51+
<%= config.bin %> <%= command.id %> --class-names TestA --class-names TestB --result-format tap --code-coverage
52+
53+
- Run Apex tests on methods specified using the standard Class.method notation; if you specify a test class without a method, the command runs all methods in the class:
54+
55+
<%= config.bin %> <%= command.id %> --tests TestA.excitingMethod --tests TestA.boringMethod --tests TestB
56+
57+
- Run Apex tests on methods specified using the standard Class.method notation with a namespace:
58+
59+
<%= config.bin %> <%= command.id %> --tests ns.TestA.excitingMethod --tests ns.TestA.boringMethod --tests ns.TestB
60+
3761
# flags.class-names.summary
3862

3963
Apex test class names to run; default is all classes.
@@ -80,9 +104,9 @@ Level of tests to run; default is RunLocalTests.
80104

81105
Here's what the levels mean:
82106

83-
- RunSpecifiedTests — Only the tests that you specify are run.
84-
- RunLocalTests — All tests in your org are run, except the ones that originate from installed managed packages.
85-
- RunAllTestsInOrg — All tests are in your org and in installed managed packages are run
107+
- RunSpecifiedTests — Only the tests that you specify in the runTests option are run. Code coverage requirements differ from the default coverage requirements when using this test level. The executed tests must cover each class and trigger in the deployment package for a minimum of 75% code coverage. This coverage is computed for each class and triggers individually, and is different than the overall coverage percentage.
108+
- RunLocalTests — All local tests in your org, including tests that originate from no-namespaced unlocked packages, are run. The tests that originate from installed managed packages and namespaced unlocked packages aren't run. This test level is the default for production deployments that include Apex classes or triggers.
109+
- RunAllTestsInOrg — All tests are run. The tests include all tests in your org.
86110

87111
# flags.wait.summary
88112

@@ -119,7 +143,7 @@ Encountered an error when processing test results
119143

120144
# apexTestReportFormatHint
121145

122-
Run "%s apex get test %s --result-format <format>" to retrieve test results in a different format.
146+
Run "sf apex get test %s --result-format <format>" to retrieve test results in a different format.
123147

124148
# outputDirHint
125149

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
22
"name": "@salesforce/plugin-apex",
33
"description": "Apex commands",
4-
"version": "3.2.0",
4+
"version": "3.2.5",
55
"author": "Salesforce",
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
8-
"@oclif/core": "^4",
9-
"@salesforce/apex-node": "^6.1.2",
10-
"@salesforce/core": "^7.4.1",
8+
"@salesforce/apex-node": "^7.0.4",
9+
"@salesforce/core": "^8.1.0",
1110
"@salesforce/kit": "^3.1.6",
12-
"@salesforce/sf-plugins-core": "^11.1.0",
11+
"@salesforce/sf-plugins-core": "^11.1.6",
1312
"ansis": "^3.2.0"
1413
},
1514
"devDependencies": {
16-
"@oclif/plugin-command-snapshot": "^5.2.3",
17-
"@salesforce/cli-plugins-testkit": "^5.3.16",
18-
"@salesforce/dev-scripts": "^10.2.0",
19-
"@salesforce/plugin-command-reference": "^3.1.2",
20-
"eslint-plugin-sf-plugin": "^1.18.9",
21-
"oclif": "^4.12.1",
15+
"@oclif/core": "^4.0.12",
16+
"@oclif/plugin-command-snapshot": "^5.2.7",
17+
"@salesforce/cli-plugins-testkit": "^5.3.18",
18+
"@salesforce/dev-scripts": "^10.2.2",
19+
"@salesforce/plugin-command-reference": "^3.1.9",
20+
"eslint-plugin-sf-plugin": "^1.18.11",
21+
"oclif": "^4.14.0",
2222
"ts-node": "^10.9.2",
2323
"typescript": "^5.5.2"
2424
},

src/commands/apex/get/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default class Test extends SfCommand<RunResult> {
5858
const testService = new TestService(conn);
5959
const result = await testService.reportAsyncResults(flags['test-run-id'], flags['code-coverage']);
6060

61-
const testReporter = new TestReporter(new Ux({ jsonEnabled: this.jsonEnabled() }), conn, this.config.bin);
61+
const testReporter = new TestReporter(new Ux({ jsonEnabled: this.jsonEnabled() }), conn);
6262

6363
return testReporter.report(result, {
6464
'output-dir': flags['output-dir'],

src/commands/apex/run/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export default class Test extends SfCommand<RunCommandResult> {
136136
}
137137

138138
if ('summary' in result) {
139-
const testReporter = new TestReporter(new Ux({ jsonEnabled: this.jsonEnabled() }), conn, this.config.bin);
139+
const testReporter = new TestReporter(new Ux({ jsonEnabled: this.jsonEnabled() }), conn);
140140
return testReporter.report(result, flags);
141141
} else {
142142
// Tests were ran asynchronously or the --wait timed out.

src/reporters/testReporter.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ export class TestReporter {
3131
*
3232
* @param ux a new Ux instance based on if the command is in json mode
3333
* @param connection a connection to the org the tests are being run against - used for getting username for hints
34-
* @param bin the bin of the cli, used for providing suggestions in the users cli
3534
*/
36-
public constructor(private readonly ux: Ux, private readonly connection: Connection, private readonly bin: string) {}
35+
public constructor(private readonly ux: Ux, private readonly connection: Connection) {}
3736

3837
public async report(
3938
result: TestResult,
@@ -208,6 +207,6 @@ export class TestReporter {
208207
if (username) {
209208
reportArgs += ` -o ${username}`;
210209
}
211-
return messages.getMessage('apexTestReportFormatHint', [this.bin, reportArgs]);
210+
return messages.getMessage('apexTestReportFormatHint', [reportArgs]);
212211
}
213212
}

test/commands/apex/get/log.test.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77
import fs from 'node:fs';
8-
import { Config } from '@oclif/core';
98
import sinon from 'sinon';
109
import { LogService } from '@salesforce/apex-node';
1110
import { expect } from 'chai';
12-
import { SfCommand } from '@salesforce/sf-plugins-core';
11+
import { stubSfCommandUx } from '@salesforce/sf-plugins-core';
1312
import { Org } from '@salesforce/core';
1413
import ansis from 'ansis';
1514
import Log, { LogGetResult } from '../../../../src/commands/apex/get/log.js';
@@ -18,14 +17,12 @@ const strip = new ansis.Ansis().strip;
1817
const logStripper = (log: LogGetResult[number]) => (typeof log === 'string' ? strip(log) : { log: strip(log.log) });
1918

2019
describe('apex:log:get', () => {
21-
let config: Config;
2220
let sandbox: sinon.SinonSandbox;
23-
let logStub: sinon.SinonStub;
21+
let uxStub: ReturnType<typeof stubSfCommandUx>;
2422

2523
beforeEach(async () => {
26-
config = await Config.load(import.meta.url);
2724
sandbox = sinon.createSandbox();
28-
logStub = sandbox.stub(SfCommand.prototype, 'log');
25+
uxStub = stubSfCommandUx(sandbox);
2926
sandbox.stub(Org, 'create').resolves({ getConnection: () => ({}) } as Org);
3027
});
3128

@@ -42,38 +39,38 @@ describe('apex:log:get', () => {
4239

4340
it('0 logs to get', async () => {
4441
sandbox.stub(LogService.prototype, 'getLogs').resolves([]);
45-
const result = await Log.run([], config);
42+
const result = await Log.run([]);
4643
expect(result).to.deep.equal([]);
47-
expect(logStub.firstCall.args[0]).to.equal('No results found');
44+
expect(uxStub.log.firstCall.args[0]).to.equal('No results found');
4845
});
4946

5047
it('outputdir will write to fs', async () => {
5148
sandbox.stub(LogService.prototype, 'getLogs').resolves([{ log: 'myLog' }]);
52-
const result = await new Log(['--output-dir', 'myDirectory'], config).run();
49+
const result = await Log.run(['--output-dir', 'myDirectory']);
5350
expect(result).to.deep.equal(['myLog']);
54-
expect(logStub.firstCall.args[0]).to.equal('Log files written to myDirectory');
51+
expect(uxStub.log.firstCall.args[0]).to.equal('Log files written to myDirectory');
5552
});
5653

5754
it('outputdir will write to fs --json', async () => {
5855
sandbox.stub(LogService.prototype, 'getLogs').resolves([{ log: 'myLog' }]);
59-
const result = await new Log(['--outputdir', 'myDirectory', '--json'], config).run();
56+
const result = await Log.run(['--outputdir', 'myDirectory', '--json']);
6057
expect(result).to.deep.equal(['myLog']);
61-
expect(logStub.firstCall.args[0]).to.equal('Log files written to myDirectory');
58+
expect(uxStub.log.firstCall.args[0]).to.equal('Log files written to myDirectory');
6259
});
6360

6461
it('multiple results', async () => {
6562
sandbox.stub(LogService.prototype, 'getLogs').resolves([{ log: 'myLog' }, { log: 'myLog2' }]);
66-
const result = (await new Log([], config).run()).map(logStripper);
63+
const result = (await Log.run([])).map(logStripper);
6764
expect(result).to.deep.equal([{ log: 'myLog' }, { log: 'myLog2' }]);
68-
expect(logStripper(logStub.firstCall.args[0] as string)).to.equal('myLog');
69-
expect(logStripper(logStub.secondCall.args[0] as string)).to.equal('myLog2');
65+
expect(logStripper(uxStub.log.firstCall.args[0] as string)).to.equal('myLog');
66+
expect(logStripper(uxStub.log.secondCall.args[0] as string)).to.equal('myLog2');
7067
});
7168

7269
it('multiple results --json', async () => {
7370
sandbox.stub(LogService.prototype, 'getLogs').resolves([{ log: 'myLog' }, { log: 'myLog2' }]);
74-
const result = (await new Log(['--json'], config).run()).map(logStripper);
71+
const result = (await Log.run(['--json'])).map(logStripper);
7572
expect(result).to.deep.equal([{ log: 'myLog' }, { log: 'myLog2' }]);
76-
expect(logStripper(logStub.firstCall.args[0] as string)).to.equal('myLog');
77-
expect(logStripper(logStub.secondCall.args[0] as string)).to.equal('myLog2');
73+
expect(logStripper(uxStub.log.firstCall.args[0] as string)).to.equal('myLog');
74+
expect(logStripper(uxStub.log.secondCall.args[0] as string)).to.equal('myLog2');
7875
});
7976
});

0 commit comments

Comments
 (0)