New answers tagged

3

There's no way to unilaterally guarantee that you'll get all dependencies correct, but here's a few ideas. Diff Names and Modify Use a git diff output to see delta changes, then for each class, add "Test" to the name. This depends on a strict naming convention, and may not work for some use cases, like flows or triggers. Query Dependencies Extract ...


3

You can't. There's no way to determine which tests could be potentially impacted by some specific change. For example, a change to a Validation Rule can potentially cause any test that performs DML on any object to fail, because automation running on the object changed could itself cause changes to the object with the Validation Rule. More or less the same ...


0

Can you please try the below test class @isTest public class OppRelatedSolutionsControllerTest { public static testMethod void method1() { Solution__c solRec = new Solution__c(); solRec.Name = 'Test Solution'; solRec.Amount__c = 582; solRec.Expected_Revenue__c = 879; insert solRec; Test.startTest(); ...


0

So it's possible to create an new instance dynamically: Type kType = Type.forName('Knowledge__kav'); if (kType != null) { Object ko = kType.newInstance(); if (ko instanceof SObject) { SObject kso = (SObject)ko; kso.put('Title', 'Test Article'); kso.put('UrlName', 'test-article'); insert kso; } }


1

Disable retrieve-test-code-coverage from settings and try this vscode extension. You can get code coverage as in Developer Console in less time. https://marketplace.visualstudio.com/items?itemName=RaffaelePreziosi.apexgetcoverage


1

In my case, I was trying to get Assignment Rules from readMetadata and here's how I mocked it: private class WebServiceMockImpl implements WebServiceMock { public void doInvoke( Object stub, Object request, Map<String, Object> response, String endpoint, String soapAction, String requestName, String responseNS, String ...


0

Well, in your test class you create an account Account acc = new Account(); acc.Name='Test'; acc.AccountNumber ='12345'; insert acc; but in the class under test you search for an account that is a person account and has to have PersonEmailset. As you haven't created a matching account, in the line Account CustomerId= [SELECT PersonContactId FROM Account ...


0

In this release I foun an error creating MultiCurrency scratchOrgs with "feature" configuration in "project-scratch-def.json" file. To solve it, I have activated the MultiCurrency from setting config file section: { "orgName": "Demo Company", "edition": "Developer", "language": "...


0

The proximate issue is that this query doesn't return anything: list<contentDocument> cd = [select id from contentdocument where id =:cvDocId]; because cv.ContentDocumentId is not automatically populated on insert, and is null here. You must query for this value before you can use it. Your unit test will actually fail if you succeed in getting ...


0

Since the coverage stops at the line where you make the callout, you must be encountering an exception. You have an empty catch block, and you're catching (and then swallowing) all exceptions. That's bad practice. It makes debugging harder, and it makes tests that should be failing pass instead. When working with async code you want more notification about ...


0

My recommendation is to avoid this problem altogether by not unit testing the Schedulable implementation via System.schedule - after all, you don't need to check that Salesforce correctly invokes your Schedulable implementation but rather that your code functions correctly. This is most easily done if your Schedulable doesn't use the SchedulableContext ...


1

I never heard about a test class waiting "for hours until it eventually decides to work" but I can give you one idea on why you get the "job already exists" error. The line below will fail if you already have a job scheduled with that name. Therefore, if somebody manually schedules the job with that name you may end up with conflicts ...


0

It is happening because of conflicts coming from parallel execution of multiple test runs. You can try disabling the 'Parallel Apex Testing' setting under Apex Test Execution settings. Steps to follow: Setup | Apex Test Execution | Option | Disable Parallel Apex Testing - True


3

As with any other method you want to cover, you have to actually call it. @IsTest static void myTest() { // setup as is Test.startTest(); DynamicApi.DynamicApiPost(); Test.stopTest(); // query results // assert behavior }


3

By default your test class can't read the records of your org. So in your method, if(testTranscripts1.size()>0) returns false and nothing happens. To allow it to see the record, you have to annotate your method with @isTest(SeeAllData=true). However, using SeeAllData is not a good idea since if anyone deletes the record named 00000089 in the org, your ...


1

As per David Reed's answer, the issue is reported against processing in the ivybat managed package and you cannot debug that - only the supplier of the package can. However, the issues could, in principle, be caused by the subscriber org configuration. For example, badly written flows without guards that repeatedly update records for object types that are ...


1

This failure is in a managed package with the namespace ivybat. The managed package is installed in your org. You can't debug managed package code, although you may be able to guess your way to a solution, such as reducing record volume that causes this trigger to run. You should contact the vendor for assistance. They're the only ones who can provide a true ...


1

You create the user using System.runAs(), and then you can create the accounts as yourself (the administrator): User testUser = ...; System.runAs(new User(Id=UserInfo.getUserId()) { insert testUser; } Account testAccount = ...; insert testAccount; Or you can do it the other way around (this is how we do it in our unit tests in production): User ...


1

Your method is apparently throwing an exception, as that's the only way this sort of situation can occur. Notice also that your return statement never executes. If your test is passing, I presume that you used a try-catch block in your unit test method, which is why it still succeeds. Never use try-catch in a unit test unless you're specifically testing for ...


4

Why is this important? Well, if you're writing a testmethod that is attempting to test partial success saves on Account deletion, you can't just mock Accounts and draft Orders, you need a different technique to get the partial save success. Things I tried: Action Result Adding OrderItems to the mocked Order Account still deletes 😞 Adding Assets to the ...


Top 50 recent answers are included