-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: shorten command to add non-unit tests
- Loading branch information
Showing
10 changed files
with
112 additions
and
23 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: tests | ||
|
||
on: | ||
push: | ||
branches-ignore: [main] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
unit-tests: | ||
uses: salesforcecli/github-workflows/.github/workflows/unitTest.yml@main | ||
nuts: | ||
needs: unit-tests | ||
uses: salesforcecli/github-workflows/.github/workflows/nut.yml@main | ||
secrets: inherit | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
fail-fast: false | ||
with: | ||
os: ${{ matrix.os }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,7 @@ node_modules | |
|
||
oclif.manifest.json | ||
|
||
oclif.lock | ||
oclif.lock | ||
|
||
stderr*.txt | ||
stdout*.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,15 +35,15 @@ sf plugins install [email protected] | |
|
||
The `apex-code-coverage-transformer` has 1 command: | ||
|
||
- `sf apex-code-coverage transformer transform` | ||
- `sf acc-transformer transform` | ||
|
||
This command needs to be ran somewhere inside your Salesforce DX git repository, whether in the root folder (recommended) or in a subfolder. This plugin will determine the root folder of this repository and read the `sfdx-project.json` file in the root folder. All package directories listed in the `sfdx-project.json` file will be processed when running this plugin. | ||
|
||
## `sf apex-code-coverage transformer transform` | ||
## `sf acc-transformer transform` | ||
|
||
``` | ||
USAGE | ||
$ sf apex-code-coverage transformer transform -j <value> -x <value> -c <value> [--json] | ||
$ sf acc-transformer transform -j <value> -x <value> -c <value> [--json] | ||
FLAGS | ||
-j, --coverage-json=<value> Path to the code coverage JSON file created by the Salesforce CLI deployment or test command. | ||
|
@@ -57,7 +57,7 @@ DESCRIPTION | |
This plugin will convert the code coverage JSON file created by the Salesforce CLI during Apex deployments and test runs into an XML accepted by tools like SonarQube. | ||
EXAMPLES | ||
$ sf apex-code-coverage transformer transform -j "coverage.json" -x "coverage.xml" -c "deploy" | ||
$ sf acc-transformer transform -j "coverage.json" -x "coverage.xml" -c "deploy" | ||
``` | ||
|
||
## Hook | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { copyFile, writeFile, rm, mkdir } from 'node:fs/promises'; | ||
import { resolve } from 'node:path'; | ||
|
||
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; | ||
import { expect } from 'chai'; | ||
|
||
describe('acc transformer NUTs', () => { | ||
let session: TestSession; | ||
|
||
const baselineClassPath = resolve('test/baselines/classes/AccountProfile.cls'); | ||
const baselineTriggerPath = resolve('test/baselines/triggers/AccountTrigger.trigger'); | ||
const deployCoverageNoExts = resolve('test/deploy_coverage_no_file_exts.json'); | ||
const deployCoverageWithExts = resolve('test/deploy_coverage_with_file_exts.json'); | ||
const testCoverage = resolve('test/test_coverage.json'); | ||
// const baselineXmlPath = resolve('test/coverage_baseline.xml'); | ||
const testXmlPath1 = resolve('coverage1.xml'); | ||
const testXmlPath2 = resolve('coverage2.xml'); | ||
const testXmlPath3 = resolve('coverage3.xml'); | ||
|
||
const configFile = { | ||
packageDirectories: [{ path: 'test/baselines', default: true }], | ||
namespace: '', | ||
sfdcLoginUrl: 'https://login.salesforce.com', | ||
sourceApiVersion: '58.0', | ||
}; | ||
const configJsonString = JSON.stringify(configFile, null, 2); | ||
|
||
before(async () => { | ||
await writeFile('sfdx-project.json', configJsonString); | ||
await mkdir('force-app/main/default/classes', { recursive: true }); | ||
await mkdir('packaged/triggers', { recursive: true }); | ||
await copyFile(baselineClassPath, 'force-app/main/default/classes/AccountProfile.cls'); | ||
await copyFile(baselineTriggerPath, 'packaged/triggers/AccountTrigger.trigger'); | ||
}); | ||
|
||
before(async () => { | ||
session = await TestSession.create({ devhubAuthStrategy: 'NONE' }); | ||
}); | ||
|
||
after(async () => { | ||
await session?.clean(); | ||
await rm('sfdx-project.json'); | ||
await rm('force-app/main/default/classes/AccountProfile.cls'); | ||
await rm('packaged/triggers/AccountTrigger.trigger'); | ||
await rm('force-app', { recursive: true }); | ||
await rm('packaged', { recursive: true }); | ||
await rm(testXmlPath1); | ||
await rm(testXmlPath2); | ||
await rm(testXmlPath3); | ||
}); | ||
|
||
it('runs transform on the deploy coverage file without file extensions.', async () => { | ||
const command = `acc-transformer transform --coverage-json "${deployCoverageNoExts}" --xml "${testXmlPath1}"`; | ||
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout; | ||
|
||
expect(output.replace('\n', '')).to.equal(`The coverage XML has been written to ${testXmlPath1}`); | ||
}); | ||
|
||
it('runs transform on the deploy coverage file with file extensions.', async () => { | ||
const command = `acc-transformer transform --coverage-json "${deployCoverageWithExts}" --xml "${testXmlPath2}"`; | ||
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout; | ||
|
||
expect(output.replace('\n', '')).to.equal(`The coverage XML has been written to ${testXmlPath2}`); | ||
}); | ||
|
||
it('runs transform on the test coverage file.', async () => { | ||
const command = `acc-transformer transform --coverage-json "${testCoverage}" --xml "${testXmlPath3}"`; | ||
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout; | ||
|
||
expect(output.replace('\n', '')).to.equal(`The coverage XML has been written to ${testXmlPath3}`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters