Linked Questions

1 vote
1 answer
6k views

Test Class for Contact [duplicate]

I have a code that is testing a batch, I am creating a contact and an Account , but the contact isn't getting linked to the account (c.AccountId = null). The same code is tested in Async window and it ...
Zame's user avatar
  • 125
-2 votes
1 answer
3k views

test class for apex class creating multiple object records [duplicate]

Can anyone helps me out in writing the test class for below apex class. I know that I should not post it here asking for this kind of questions but as I am new to apex and I need to deploy so I was ...
Sainath's user avatar
  • 11
0 votes
1 answer
3k views

How to write test class for below Vf Page Controller [duplicate]

Class public with sharing class CreateQuotePDFController { public list<QuoteLineItem> quoteLineItemsList{get;set;} public Id getid{get;set;} public Double grandTotalTax{get;set;} ...
Wheels-Of- My Soul's user avatar
0 votes
1 answer
908 views

how to write Test class for generate Random String method present in a class in salesforce [duplicate]

@AuraEnabled public static Integer generateRandomString() { try{ return Math.round((Math.random() * (900000) + 100000)); } catch (Exception e) { throw e; } }
Swarnim's user avatar
1 vote
1 answer
2k views

How to test trigger that compares Trigger.new with Trigger.old [duplicate]

I have a simple trigger that runs on Account update, and the only logic is a check to whether or now BillingPostalCode changes or not. This is my code: trigger ZipCodeUpdated on Account (before update)...
Santiago Barboza's user avatar
-3 votes
1 answer
2k views

Test class trigger.NewMap trigger.oldMap on opportunity [duplicate]

I need to write a test class on my OpportunityTriggerHandler and I'm having some difficulties to define how to construct the logic & scenarios in my test to test and the data to build in my test ...
Fatih's user avatar
  • 1
-2 votes
1 answer
677 views

Test Class for a simple Apex Class [duplicate]

I am trying to write a test class for a simple Apex Class which sets the status of the Case to be Closed like below public class updateCaseRecord { @AuraEnabled public static void ...
user81642's user avatar
  • 687
-1 votes
3 answers
837 views

How to write a test class for this below code can anyone help me [duplicate]

I want to write a test class to achieve 100 % code coverage for this below code can anyone help me to solve this problem i don't know how to write a test class for using this trigger Trigger: trigger ...
Jayati Shukla's user avatar
0 votes
0 answers
868 views

Need Help with a test class to my apex class that attaches a Visualforce Page pdf to the quote [duplicate]

I found a way to write an apex class that attaches my quote which is generated by an vf page as a pdf to my quote object. Writing the test class is even a bigger problem for me. I get to 36% coverage ...
Thomas Kayser-Eichberg's user avatar
-2 votes
1 answer
441 views

Add test method to your test class error getting, please help how to resolve [duplicate]

public with sharing class CreateQuotePDFController { public list<QuoteLineItem> quoteLineItemsList{get;set;} public Id getid{get;set;} public Double grandTotalTax{get;set;} ...
user105753's user avatar
0 votes
1 answer
489 views

Test Class Coverage for Apex Controller [duplicate]

I need help in writing test class for following apex class. Could anyone please suggest how to create test data,test the following method defined in apex class with positive and negative scenarios and ...
Rose 's user avatar
  • 123
0 votes
1 answer
538 views

How to get rid of this System.ListException: List index out of bounds: 0 error in my test class [duplicate]

I am trying to create a new case with record type to cover the lines in my apex class but throwing the inbound error. please help me to cover the lines This is the full method public void ...
Teja 's user avatar
  • 15
0 votes
1 answer
318 views

Use Map instead of For loop in my Apex Trigger [duplicate]

I'm new to coding and I need help in modifying the apex trigger below to the correct one. Can you also help me in creating a test class for this? Thank you so much! trigger UpdateLadderedFields on ...
Salesforce Dev's user avatar
-2 votes
1 answer
538 views

How to cover the below lines of code in a test class? [duplicate]

Please help me in order to write the test class for the below lines of code: Id objUser = UserInfo.getUserId(); UserRecordAccess objRecordAccess = [Select RecordId, HasEditAccess From UserRecordAccess ...
Salesforce Developer's user avatar
0 votes
1 answer
352 views

Test Class for Trigger on Event [duplicate]

I am new to Salesforce and I am writing a test class for the trigger. Can anyone tell me how to write a test class for the trigger below? trigger QBRNewRec on Account (After insert, After Update) { ...
Monica Manickam's user avatar
0 votes
0 answers
436 views

How to Write Test Class for If Condition [duplicate]

How to Write Test Class for If Condition... This is my Trigger... trigger TierPricingOffers on OpportunityLineItem (before Insert,before Update,before delete) { if(trigger.isBefore) { Set<...
Kumar's user avatar
  • 1
-1 votes
2 answers
492 views

What is test class for below code? [duplicate]

public class UtilityClass { public static String getDescribedObjects( List lstSObjectType ) { // Globally desribe all the objects Map<String, SObjectType> globalDescribe = Schema....
aishwarya gotarkar's user avatar
0 votes
0 answers
350 views

Test Class for Dynamic SOQL [duplicate]

Pretty new with salesforce dev. So forgive me. I am doing a SOQL query and then updating records. The trick here is . I am grabbing my query from two custom fields which are in the Custom Settings . ...
deboniar's user avatar
1 vote
0 answers
332 views

Test Class for Batch Apex Schedulable batch Process [duplicate]

I need help in writing test class for the below Apex Schedulable batch Process. Can anyone help me out. global class CLM_Batch_ExpireAgreements implements Database.Batchable<sObject>,...
hemanth kumar's user avatar
0 votes
1 answer
244 views

Test Class with wrapper [duplicate]

I have a problema with a Class test in the wrapper class.. This is mi class and doesn't have any error: public class ValeDeSalida_cls { private ApexPages.StandardController sc; public String ...
Lizeth Mendoza's user avatar
0 votes
0 answers
228 views

Apex Test Class is Failing - (System.QueryException: List has no rows for assignment to SObject) [duplicate]

I am brand new to coding and this is my first test class. I have spent hours trying to get it to pass. Apex Trigger That I am Testing trigger RenameTransaction on Financial_Transaction__c (before ...
David Nava's user avatar
0 votes
0 answers
242 views

Please I need help writing a test class for this scheduled class [duplicate]

public with sharing class Repeating_Scheduler implements Schedulable{ private final String JOB_NAME = 'PriceBookEntryHandler Job'; private final Integer ONE_MINUTE = 1; private void ...
sams ameen's user avatar
0 votes
0 answers
233 views

Creating an Apex Test Class for Apex class that handles a webhook integration when an opportunity in Salesforce moves to the 'Closed Won' stage [duplicate]

How can I create a test class on the below trigger? public class webhookOpportunityStageNameClosedWon { // call method 'handleOpportunityStageNameClosedWon' in the '...
Cat's user avatar
  • 1
-3 votes
1 answer
136 views

Test class not sure how to write for this code [duplicate]

I have written following apex class: public with sharing class Persmissionset { @AuraEnabled public static PermissionPagerWrapper fetchPermission(Decimal pageNumber ,Integer recordToDisply) { ...
Pushpesh Bisht's user avatar
0 votes
1 answer
267 views

How to make Test class for an invocable Lead Convert class [duplicate]

I'm trying to convert a lead by using Apex within Flow. I have this code, that I've found online for doing so. I just can't seem to figure out how to make a test class for it so that I can deploy it ...
Adam Parsley's user avatar
-1 votes
1 answer
93 views

How to write Test class for the below [duplicate]

Apex class: public class ProdImedComAr { public class Respuesta { public Integer Codigo; public String Descripcion; public Long NroOperacion; public String ...
Dinesh Prasad's user avatar
0 votes
0 answers
150 views

Writing test Class - Code Coverage 0% [duplicate]

Working on creating a test class for my class in my sandbox and I am receiving a code coverage 0% in the dev console. The console isn't highlightning the lines that need to be covered in red either. ...
Gabriel M's user avatar
  • 116
-3 votes
1 answer
93 views

Code Coverage for IF statement [duplicate]

May I know how I can create a code coverage for if statement code? Here is my if statement code: @AuraEnabled public static void submitFinalApproval(Id recordId) { //1. RS if(...
Atiqah's user avatar
  • 23
0 votes
0 answers
145 views

Creating a Test Class for 2 Classes [duplicate]

In order for Territory Assignment rules to fire on Account creation and Update, I have got 2 Classes working (with Triggers), however I am struggling to create a Test class for these, any help would ...
Liam Heppenstall's user avatar
0 votes
0 answers
130 views

Test class for RequestData class [duplicate]

@HttpPost global static List<HHSurvey> getHHSurveyList() { RestRequest req = RestContext.request; RequestData mRequestData = (RequestData)JSON.deserialize(req.requestBody.toString()...
user avatar
-2 votes
1 answer
120 views

Test Case for custom object [duplicate]

How to write test case for below method Custom Object : SAM_Request__c Global Variable :crossChargeInfoSetFlag , samAdminFlag , samTeamFlag boolean crossChargeInfoSetFlagMethod(SAM_Request__c ...
SAK's user avatar
  • 15
0 votes
0 answers
123 views

Create test class to achieve 75% code coverage needed for a Apex Trigger and Class [duplicate]

I wish to update a field from one custom object (Career Path) to another object (Contact details) based on whether a checkbox (Current) is true. Essentially, it updates the Contacts details with the ...
Chloe Brown's user avatar
0 votes
0 answers
113 views

Getting Apex test class to 75% [duplicate]

I am migrating and Apex Visualforce page and controller from a Sandbox to Production for the first time. The page is an update of a community registration with a few minor changes (removing a field, ...
Miranda's user avatar
0 votes
1 answer
108 views

Writing Test Classes in Apex [duplicate]

Is there any link (eg: w3schools) where one can practice writing the test classes in Apex ? I am new to Salesforce and hence having confusion in writing the test classes in Apex.
Salesforce Developer's user avatar
-2 votes
1 answer
79 views

Can you please provide test class for this [duplicate]

global class LastLoginEmailJObs implements Schedulable { global void execute(SchedulableContext SC) { List<Messaging.SingleEmailMessage> mails = new List<Messaging....
user123449's user avatar
-2 votes
1 answer
55 views

How to write test class for this? [duplicate]

public with sharing class ToggleController { @AuraEnabled(cacheable=true) public static List< Contact > fetchContact (Id accId, String status) { return [SELECT Status_c, ...
Guest's user avatar
  • 3
0 votes
0 answers
67 views

Test class - code coverage help [duplicate]

I need help on test class, this is my class: When creating a task of type (Phone Call or Last Face to Face) then update the account fields I have a trigger: trigger TaskTrigger on Task (after ...
Vk sfdc's user avatar
0 votes
1 answer
50 views

Developing A Test Class [duplicate]

I've written Apex classes but this is my first time written a test class. I've read a number of sources and watch videos but I don't grasp the foundation to get a test to successfully cover my code. ...
Len Cadet's user avatar
-1 votes
1 answer
57 views

I'm a novice developer, please help with writing a test class for this code.Thanks [duplicate]

global class converterSchedule implements Schedulable { global void execute(SchedulableContext ctx) { List<Exchange_rate__c> exchange = [SELECT Date__c, GBP__c, USD__c, EUR__c, ...
Gari Vudi's user avatar
0 votes
0 answers
58 views

How do I write test class for the below code? [duplicate]

I am new to Salesforce and I was playing around. So I have a vf page in which I am displaying a modal and closing it once its done. The functionality is working well. I'm just stuck at how to write a ...
Rohith Wardole's user avatar
0 votes
0 answers
48 views

Write a Test for extension HELP [duplicate]

Hi Im new working with apexcode and I Crate a Class in sanbox, but when I try to upload to production it says that my coverage code is 73% this is my code public with sharing class ...
noebrenes's user avatar
0 votes
0 answers
48 views

UNIT TEST TRIGGER - Coverage Test Trigger and using System.assertEquals [duplicate]

Hello, I'm new to salesforce and I have a problem with test coverage and System.assertEquals My coverage is insufficient And I get this as an error: Errors : System.AssertException: Assertion ...
Alluche's user avatar
0 votes
0 answers
45 views

Apex Test Class for SOQL [duplicate]

I'm having trouble providing code coverage for my Apex Class. Apex Class public class CSMetricsDashboardController { public CS_Metrics_Dashboard__c dashboard {get;set;} public ...
Kayle's user avatar
  • 1
0 votes
0 answers
45 views

Help me build a test class [duplicate]

Hi I am new in Apex Programming, can you help me build a test class for the following code. Thanks. public static void caseClose(Map<Id, SObject> newMap, Map<Id, SObject> oldMap){ ...
Lhanz_404's user avatar
0 votes
0 answers
45 views

Apex triggers and Apex test class [duplicate]

I have built this trigger: trigger OpportunityTrigger on Opportunity (before insert) { List<Opportunity> lstOpportunity = (List<Opportunity>) Trigger.new; if(lstOpportunity.get(0)...
Kenneth's user avatar
-2 votes
1 answer
35 views

in test class should pass lastweek is not equal to currentweek [duplicate]

Main class global with sharing class FCSTWeeklyCopyBatchCtl implements DataBase.Batchable<sObject> { public Date todaysDate; public String dayOfWeek; public Date mstartDate; ...
satya's user avatar
  • 1
-1 votes
1 answer
44 views

How to write test for this trigger [duplicate]

Want to write Test case and unit test for this trigger trigger Autoleadconversion on Lead (after insert, after update) { for (Lead lead : Trigger.new) { if (lead.isConverted ==...
aswin balaji's user avatar
0 votes
0 answers
43 views

COVER IF CONDITIONS [duplicate]

I have an apex class and a Test class already created. Now have added few IF CONDITIONS in my apex class, but I am unable to cover those in my TEST CLASS. APEX CLASS: global with sharing class ...
rajesh adwani's user avatar
0 votes
0 answers
42 views

How do I write a test for my Trigger? [duplicate]

I'm currently in the test phase of my project. I suppose to write a test on my triggers if someone has the good syntax for that (I've tried but it didn't work): here my triggers 1/ trigger ...
Laetitia's user avatar
0 votes
0 answers
39 views

Hi, Iam new to salesforce, cant able to write test class for below code [duplicate]

public class countthecontacts { public void insertcontact(){ list<Account> acclist = new list<Account>(); list<contact> conlist = new list<contact>(); ...
keerthi's user avatar

15 30 50 per page