4

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 when I look back through previous ApexTestRunResult records. In my cases I had parallel testing enabled. I'm assuming there is a race condition around multiple ...


3

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 defined as a percentage is executable lives covered, so your wrapper class requires no test class and does not impact your org's coverage.


2

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 to I can see ApexTestRunResult records dating back to 14-Jan-20 1:36:57 AM. So about a month ago. Note that all the ApexTestRunResult records are parented by an ...


2

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 test to ensure there are records for your test. If you just need to ensure "yes we have history, yes those fields have values" it's better than not testing the ...


2

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 passes if it's true. You can either do something more valuable with that assert, or remove it altogether.


2

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 testGetPaymentRequests() { User u = createUsersAndReturnOne(); System.runAs(u) { Coop_Campaign__c coopCampaign = createCoopCampaign(); CoopCampaignController....


2

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. public with sharing class SiteFacade { @TestVisible private static String strSiteId = 'DummySiteId'; public static String getSiteId(){ ...


2

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 so that you can utilize dependency injection to control its return value. But that seems like overkill here. There's a much simpler option: refactor your code ...


2

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 = new Case(); ... newCase.RecordTypeId = '{get value from describe call}'; newCase.Close_Code__c = 'test'; insert newCase;


1

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+shift+p and type "turn on replay" and you'll see that option appearing). Now if you click on this feature, (which shows up right next to the Run Test at ...


1

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 schedule, you can use the basic core features of Windows or Linux systems to run a Windows Task or Cronjob, deploy a container to Heroku or AWS, etc, or you ...


1

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:run has a --wait argument which defaults to 6 minutes This has always been interpreted as "if the command doesn't return within this time limit, then TIMEOUT" ...


1

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 Coverage FROM ApexCodeCoverage WHERE ApexClassOrTrigger = ‘01pD000000066GR’ AND ApexTestClass = ‘01pD000000064pu’ Coverage includes the following fields: ...


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