4 votes

ApexTestRunResult's status is set to complete and all tests pass, but the enqueued and completed count do not match

From the ApexTestRunResult docs: MethodsCompleted The total number of methods completed during the test run. This value is updated after each class is run. I'm seeing this discrepancy as well ...
user avatar
3 votes
Accepted

test class for wrapper class in apex

Your class is not covered because it contains no executable lines of code. There is nothing to cover. It is not necessary to add a constructor for the purpose of simulating coverage. Code coverage is ...
user avatar
  • 87.3k
2 votes
Accepted

Missing ApexTestRunResult Data

They most certainly do get automatically deleted. If they weren't purged periodically they would eventually add up to a significant number of records. Looking in the Dev org I'm currently connected ...
user avatar
2 votes

Unable to cover test class for history object

History records aren't created in test contexts, meaning your test will have no records and therefore no coverage. Depending on the test you might be able to get away with using seeAllData in your ...
user avatar
  • 8,565
2 votes
Accepted

test classes fail after updating a fields length and its datatype

It's failing because of System.assert(FALSE);. This means it's always going to fail. Usually, you wouldn't hardcode a boolean value when using assert. If you pass something into assert the test only ...
user avatar
2 votes
Accepted

Change Set Deployment - Code coverage failure

Try to update your test class as below and then run test class again and check, let me know any error: @isTest private class PaymentRequestControllerTests { @isTest static void ...
user avatar
2 votes
Accepted

Test Coverage Issue with Site.getSiteId()

Thanks to @Robert Sösemann, I believe you can apply Facade logic for all Platform methods. You can just change the return type to String, because all Ids are string, but not all strings are ID in apex....
user avatar
2 votes
Accepted

Refactoring Help for main class or test code coverage

You can't override the return value of URL.getSalesforceBaseUrl() in a test class. There's two possible approaches here. One is to factor out the code that calls that method into a separate code unit ...
user avatar
  • 87.3k
2 votes
Accepted

DEBUG|Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field

During the insert the record type assignment is missing and the default record type may not have the picklist value that you are trying to insert with, so add the record type assignment- Case newCase =...
user avatar
  • 17.8k
1 vote
Accepted

Debug Test and Debug All Tests for apex unit tests in VSCodedx

As @sfdcfox says in his comment, I needed to first turn on the replay debugger and then run either Debug All Tests or Debug Test. (To turn on the replay debugger in vscode, command+shif+p/control+...
user avatar
  • 620
1 vote

How to Schedule Run all apex tests on daily basis

There are many, many ways to automate it. You can subscribe to an app like GearSet to schedule automations, you can set up a CI/CD (Continuous Integration/Continuous Delivery) system to run tests on a ...
user avatar
  • 438k
1 vote
Accepted

Apex test run doesn't report back to sfdx

Could your problem be related to https://success.salesforce.com/answers?id=9063A000000t5onQAA "What has changed with the sfdx force:apex:test:run command since November 8th 2018 sfdx force:apex:test:...
user avatar
  • 48
1 vote
Accepted

how to get Percentage coverage of each ApexClass through SOQL

To query for code coverage, specify an Apex class, test class, or both. The returned JSON or XML object will contain two lists of integers: one for covered and one for uncovered lines. SELECT ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible