Linked Questions
115 questions linked to/from How do I write an Apex unit test?
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 ...
-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 ...
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;}
...
0
votes
1
answer
907
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;
}
}
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)...
-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 ...
-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 ...
-1
votes
3
answers
836
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 ...
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 ...
-2
votes
1
answer
440
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;}
...
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 ...
0
votes
1
answer
537
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 ...
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 ...
-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 ...
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) {
...