I have an org that has approx 530 test classes .I am currently working on a nodejs project that uses the sfdx commands to run the tests in the org and then generate code coverage report, analyze and classify them so that I can use the classified data to find what apex class lines are covered by which test classes/methods.
Since the amount of test classes are very large and salesforce removes coverage data if the records exceed 10K (which happens because of such a large amount of classes, triggers and test classes), I have tried to implement batches of tests to be run.
lets say the batch consists of Test_1,Test_2,.....,Test_10. The command I am using is given below.
sfdx force:apex:test:run --codecoverage -r json --classnames "Test_1,Test_2,.....,Test_10" -u testOrg --outputdir path/to/folder
The problem here is
- command blocks the script until the test are completed and overall coverage is calculated.
- after completion testRunId is not returned.
- with each subsequent run, previous test coverage data is also included in the output which is unrequired.
Is there anyway to run the command such that coverage data is only provided for the tests included in the batch?
Try to seperate it to multicommands, what you will you gain this way ?
3. Previous test coverage data is NOT included in the output. each command calculate its test code coverage