apextestlist 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/lib/commands/apextests/list.d.ts +1 -0
- package/lib/commands/apextests/list.js +31 -4
- package/lib/commands/apextests/list.js.map +1 -1
- package/lib/helpers/validateTests.d.ts +5 -0
- package/lib/helpers/validateTests.js +48 -0
- package/lib/helpers/validateTests.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/messages/apextests.list.md +12 -11
- package/oclif.lock +2086 -2548
- package/oclif.manifest.json +15 -5
- package/package.json +24 -8
package/README.md
CHANGED
|
@@ -4,9 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
A plugin that generates a list of tests that your, ideally, automated process should run, so you can save time by not running all tests in your Salesforce org and also save time by not specifying them manually.
|
|
6
6
|
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Simply issue a install command with `sf`, as in:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
sf plugins install apextestlist
|
|
13
|
+
```
|
|
14
|
+
|
|
7
15
|
## Usage
|
|
8
16
|
|
|
9
|
-
List all files specified in the classes
|
|
17
|
+
List all files specified in the classes in your package directories and have the result be in the format for the CLI.
|
|
10
18
|
|
|
11
19
|
The classes should have a comment starting with `@Tests` somewhere. This is what the tool reads to return the tests. For example, the `Sample.cls` file in the `samples` folder contains a comment like this:
|
|
12
20
|
|
|
@@ -19,12 +27,12 @@ public class Sample {
|
|
|
19
27
|
|
|
20
28
|
In the context of this plugin, this annotation/comment on the class means that _the tests that should cover this test class are called `SampleTest` and `SuperSampleTest`_.
|
|
21
29
|
|
|
22
|
-
> Note:
|
|
30
|
+
> Note: By default, this tool does not check if those classes exist within your project, so make sure to keep the annotations up-to-date. If you want to check that test annotations are found in your package directories, provide the optional `--ignore-missing-tests` Boolean flag. When the flag is provided, a warning will be printed for each test annotation it is unable to find in any of your package directories and will not add those missing annotations to the final output.
|
|
23
31
|
|
|
24
32
|
Then, assuming you want to run only the tests provided at the top level of your classes, use the command as follows:
|
|
25
33
|
|
|
26
34
|
```sh
|
|
27
|
-
sf apextests list --
|
|
35
|
+
sf apextests list --format sf
|
|
28
36
|
$ --tests SampleTest SuperSampleTest Sample2Test SuperSample2Test
|
|
29
37
|
```
|
|
30
38
|
|
|
@@ -10,6 +10,7 @@ export default class ApextestsList extends SfCommand<ApextestsListResult> {
|
|
|
10
10
|
static readonly flags: {
|
|
11
11
|
format: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
12
|
manifest: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'ignore-missing-tests': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
14
|
};
|
|
14
15
|
protected static getConcurrencyThreshold(): number;
|
|
15
16
|
private static parseTestsNames;
|
|
@@ -7,6 +7,7 @@ import { Messages } from '@salesforce/core';
|
|
|
7
7
|
import { queue } from 'async';
|
|
8
8
|
import { Parser } from 'xml2js';
|
|
9
9
|
import { getPackageDirectories } from '../../helpers/getPackageDirectories.js';
|
|
10
|
+
import { validateTests } from '../../helpers/validateTests.js';
|
|
10
11
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
11
12
|
const messages = Messages.loadMessages('apextestlist', 'apextests.list');
|
|
12
13
|
const TEST_NAME_REGEX = /(@(Tests|TestSuites)).+/g;
|
|
@@ -27,6 +28,13 @@ export default class ApextestsList extends SfCommand {
|
|
|
27
28
|
char: 'x',
|
|
28
29
|
required: false,
|
|
29
30
|
}),
|
|
31
|
+
'ignore-missing-tests': Flags.boolean({
|
|
32
|
+
summary: messages.getMessage('flags.ignore-missing-tests.summary'),
|
|
33
|
+
description: messages.getMessage('flags.ignore-missing-tests.description'),
|
|
34
|
+
required: false,
|
|
35
|
+
char: 's',
|
|
36
|
+
default: false,
|
|
37
|
+
}),
|
|
30
38
|
};
|
|
31
39
|
static getConcurrencyThreshold() {
|
|
32
40
|
const AVAILABLE_PARALLELISM = availableParallelism ? availableParallelism() : Infinity;
|
|
@@ -124,6 +132,7 @@ export default class ApextestsList extends SfCommand {
|
|
|
124
132
|
const { flags } = await this.parse(ApextestsList);
|
|
125
133
|
const format = flags.format ?? 'sf';
|
|
126
134
|
const manifest = flags.manifest ?? undefined;
|
|
135
|
+
const ignoreMissingTests = flags['ignore-missing-tests'] ?? false;
|
|
127
136
|
let result = null;
|
|
128
137
|
let testClassesNames = null;
|
|
129
138
|
// Get package directories
|
|
@@ -137,11 +146,29 @@ export default class ApextestsList extends SfCommand {
|
|
|
137
146
|
const testMethodsInDir = await ApextestsList.searchTestClasses(directory, testClassesNames);
|
|
138
147
|
allTestMethods.push(...testMethodsInDir);
|
|
139
148
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
149
|
+
// Ensure all test methods are unique by using a Set
|
|
150
|
+
let finalTestMethods = Array.from(new Set(allTestMethods.map((test) => test.trim())));
|
|
151
|
+
// If ignore-missing-tests is true, validate the test methods
|
|
152
|
+
if (ignoreMissingTests) {
|
|
153
|
+
const { validatedTests, warnings } = await validateTests(finalTestMethods, packageDirectories);
|
|
154
|
+
if (validatedTests.length > 0) {
|
|
155
|
+
finalTestMethods = validatedTests;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
throw new Error('No test methods declared in your annotations were found in your package directories.');
|
|
159
|
+
}
|
|
160
|
+
// Log any warnings
|
|
161
|
+
if (warnings.length > 0) {
|
|
162
|
+
warnings.forEach((warning) => {
|
|
163
|
+
this.warn(warning);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
finalTestMethods.sort((a, b) => a.localeCompare(b));
|
|
168
|
+
if (finalTestMethods.length > 0) {
|
|
169
|
+
result = ApextestsList.formatList(format, finalTestMethods);
|
|
143
170
|
}
|
|
144
|
-
|
|
171
|
+
else {
|
|
145
172
|
throw new Error('No test methods found');
|
|
146
173
|
}
|
|
147
174
|
this.log((await result).command);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/apextests/list.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AAErC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/apextests/list.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AAErC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,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EF,6DAA6D;QAC7D,IAAI,kBAAkB,EAAE,CAAC;YACvB,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,MAAM,aAAa,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;YAE/F,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC9B,gBAAgB,GAAG,cAAc,CAAC;YACpC,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,sFAAsF,CAAC,CAAC;YAC1G,CAAC;YAED,mBAAmB;YACnB,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxB,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;oBAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACrB,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QAEpD,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAC9D,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;QACjC,OAAO,MAAM,CAAC;IAChB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function validateTests(unvalidatedTests: string[], packageDirectories: string[]): Promise<{
|
|
2
|
+
validatedTests: string[];
|
|
3
|
+
warnings: string[];
|
|
4
|
+
}>;
|
|
5
|
+
export declare function findFilePath(fileName: string, packageDirectories: string[]): Promise<string | undefined>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* eslint-disable no-await-in-loop */
|
|
3
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
export async function validateTests(unvalidatedTests, packageDirectories) {
|
|
6
|
+
const warnings = [];
|
|
7
|
+
const validatedTests = [];
|
|
8
|
+
for (const unvalidatedTest of unvalidatedTests) {
|
|
9
|
+
// Pass the test method with the ".cls" extension
|
|
10
|
+
const testPath = await findFilePath(`${unvalidatedTest}.cls`, packageDirectories);
|
|
11
|
+
if (testPath === undefined) {
|
|
12
|
+
warnings.push(`The test method ${unvalidatedTest}.cls was not found in any package directory.`);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
validatedTests.push(unvalidatedTest);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return { validatedTests, warnings };
|
|
19
|
+
}
|
|
20
|
+
export async function findFilePath(fileName, packageDirectories) {
|
|
21
|
+
let relativeFilePath;
|
|
22
|
+
for (const directory of packageDirectories) {
|
|
23
|
+
relativeFilePath = await searchRecursively(fileName, directory);
|
|
24
|
+
if (relativeFilePath !== undefined) {
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return relativeFilePath;
|
|
29
|
+
}
|
|
30
|
+
async function searchRecursively(fileName, dxDirectory) {
|
|
31
|
+
const files = await readdir(dxDirectory);
|
|
32
|
+
for (const file of files) {
|
|
33
|
+
const filePath = join(dxDirectory, file);
|
|
34
|
+
const stats = await stat(filePath);
|
|
35
|
+
if (stats.isDirectory()) {
|
|
36
|
+
// Recursively search inside subdirectories
|
|
37
|
+
const result = await searchRecursively(fileName, filePath);
|
|
38
|
+
if (result) {
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (file === fileName) {
|
|
43
|
+
return filePath;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=validateTests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateTests.js","sourceRoot":"","sources":["../../src/helpers/validateTests.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AAErC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,gBAA0B,EAC1B,kBAA4B;IAE5B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,cAAc,GAAa,EAAE,CAAC;IAEpC,KAAK,MAAM,eAAe,IAAI,gBAAgB,EAAE,CAAC;QAC/C,iDAAiD;QACjD,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,GAAG,eAAe,MAAM,EAAE,kBAAkB,CAAC,CAAC;QAClF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,QAAQ,CAAC,IAAI,CAAC,mBAAmB,eAAe,8CAA8C,CAAC,CAAC;QAClG,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IACD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC;AACtC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAgB,EAAE,kBAA4B;IAC/E,IAAI,gBAAoC,CAAC;IACzC,KAAK,MAAM,SAAS,IAAI,kBAAkB,EAAE,CAAC;QAC3C,gBAAgB,GAAG,MAAM,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAChE,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACnC,MAAM;QACR,CAAC;IACH,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,KAAK,UAAU,iBAAiB,CAAC,QAAgB,EAAE,WAAmB;IACpE,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACzC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,2CAA2C;YAC3C,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAC3D,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;aAAM,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe,EAAE,CAAC"}
|
|
@@ -4,15 +4,7 @@ List
|
|
|
4
4
|
|
|
5
5
|
# description
|
|
6
6
|
|
|
7
|
-
Lists tests in a package.xml file or from
|
|
8
|
-
|
|
9
|
-
# flags.directory.summary
|
|
10
|
-
|
|
11
|
-
Directory name. Defaults to the current working directory.
|
|
12
|
-
|
|
13
|
-
# flags.directory.description
|
|
14
|
-
|
|
15
|
-
Usually, if you run this command at the root of your Salesforce DX project, it means that the directory points to the original "force-app" folder (even if you have renamed it to something else). If you wish to limit the usage to a specific module, specify the folder with this flag.
|
|
7
|
+
Lists tests in a package.xml file or from your package directories.
|
|
16
8
|
|
|
17
9
|
# flags.format.summary
|
|
18
10
|
|
|
@@ -28,10 +20,19 @@ Manifest XML file.
|
|
|
28
20
|
|
|
29
21
|
# flags.manifest.description
|
|
30
22
|
|
|
31
|
-
When you specify a manifest file, the plugin will not search directories for all classes with annotations, but instead will read the manifest file and search for those classes within
|
|
23
|
+
When you specify a manifest file, the plugin will not search directories for all classes with annotations, but instead will read the manifest file and search for those classes within your package directories.
|
|
24
|
+
|
|
25
|
+
# flags.ignore-missing-tests.summary
|
|
26
|
+
|
|
27
|
+
Ignore missing test methods.
|
|
28
|
+
|
|
29
|
+
# flags.ignore-missing-tests.description
|
|
30
|
+
|
|
31
|
+
If provided, ignore test methods that are not found in any of the package directories.
|
|
32
32
|
|
|
33
33
|
# examples
|
|
34
34
|
|
|
35
35
|
- <%= config.bin %> <%= command.id %> --format csv
|
|
36
|
-
- <%= config.bin %> <%= command.id %> --format sf
|
|
36
|
+
- <%= config.bin %> <%= command.id %> --format sf
|
|
37
37
|
- <%= config.bin %> <%= command.id %> --format sf --manifest package.xml
|
|
38
|
+
- <%= config.bin %> <%= command.id %> --format sf --manifest package.xml --ignore-missing-tests
|