Questions tagged [test-setup]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
40 views

How can i test my Apex method

I am not sure how to write test class for this method. Any help would be greatly appreciated! @AuraEnabled(cacheable=true) public static List<Map<String, String>> getPickListValues() { ...
1
vote
2answers
69 views

How to use a constant in SOQL in a test class

I have the following test class: @isTest(SeeAllData=false) private with sharing class classNameTest { @isTest static testMethod void methodName(){ // declare a constant ...
0
votes
0answers
52 views

Query in Batch Apex returns "List has no rows for assignment to SObject" [duplicate]

I have test class where I am using a csv file to insert 200 records Account data. First 100 are like: remaining 100 are like: I am using above created test class to test a batch apex class which has ...
0
votes
1answer
68 views

Cannot insert a quotelineitem in my Test Class

I try to insert a quotelineitem in my test class but it fails with this error ,Please help me to resolve this issue . See below my code used in the test class Quote quote = new Quote(Name = 'devis1' ,...
0
votes
1answer
146 views

Test Coverage for trigger on ActionCadeneSteptracker CDC

We are working on Updating Lead status on meaningful connect of call in HVS (High Velocity Sales), so we went ahead with the proposed solution of creating CDC on ActionCadenceStepTracker object. https:...
0
votes
2answers
41 views

How to test Job states for a Apex Test with CronTrigger being read only?

I have the following function in a class that implements System.Schedulable: @TestVisible private void rescheduleJob(CronTrigger me, ISchedulable item, MySchedulableContext myCtx) { if (me....
0
votes
0answers
72 views

How to update non setup objects in test class

I have a test class where I queried Email template made changes and updated it. While running test class I am getting Salesforce Internal Error. Can someone help me how to fix the issue. //Test Class @...
0
votes
0answers
34 views

How Do You Test Multi-Currency Logic?

You cannot setup any currency during apex tests, and therefore any logic that works on the currency of records is untestable. Am I correct? The CurrencyType does not support DML (https://developer....
0
votes
1answer
26 views

Setup and NonSetup object insertion in Test Class

we've a factory class method to create sObject: Class: DataFactory: public static SObject createSObject(SObject sObj, String defaultClassName, Boolean doInsert) { SObject retObject = ...
0
votes
0answers
50 views

Where is the data in batch class coming from?

First of all, I'm very new to salesforce so It's possible that I'm ignoring something very basic. I was writing a test class for the following batch (I've removed all the irrelevant parts). global ...
0
votes
1answer
41 views

Creating a dummy Visualforce page for an apex test class

Im working on creating a test class for two apex classes(one is scheduled another is batch apex. The scheduled is linked to the batch apex to have it run regularly.) The issue that I am running into ...
-1
votes
2answers
41 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....
1
vote
1answer
54 views

Test Class Id Error

I trying to get better and have built a trigger/test class using my knowledge I have learned however I am running into an error with the test class that for some reason I just cannot resolve and ...
1
vote
1answer
87 views

Mocking Object list issue

This question is sort of a continuation to this question. I have this method: public static void sendMail(List<Object> selectedRows) { if (selectedRows.size() > 0) { for (...
1
vote
1answer
358 views

how to mock Object list in a test class?

This is a method in my apex controller class: @AuraEnabled public static void sendMail(List<Object> selectedRows) { if (selectedRows.size() > 0) { for (Object obj : ...
0
votes
1answer
32 views

No code coverage in sandbox and partial sandbox before preparing changeset

we have developed one solution in Salesforce in the developer sandbox the solution contains the Apex Class,Trigger, Custom Objet and LWC. Eventually, We are planning to release this solution as a ...
0
votes
1answer
1k views

First error: Script-thrown exception - in the Apex Job Que after migrating an Apex Trigger and Apex class into a testing production sandbox

I have just used changesets to move an Apex Class & Trigger into a production testing sandbox. When I create a new contact in my development sandbox, I can click a checkbox which then calls the ...
1
vote
3answers
160 views

Is it really needed to check whether a list has a record in a test class?

I have a scenario like this, I have created Opportunities in a Test setup and tried to access it in a test method to clone that record like, testSetup { // Create a list of Opportunity Records. ...
0
votes
0answers
62 views

SOQL EventRelation is Test Class

The issue with SOQL on EventRelation filtered by Relation.Type is working as expected during normal execution. However, while executing the following LOC in test class it causes failure. Code: List<...
0
votes
1answer
198 views

@InvocableVariables in Apex test class

I am having difficulty writing tests for the apex class. This is my first time working with apex classes and I don't understand how to send to @InvocableVariable. I've read answers to similar ...
0
votes
2answers
31 views

Reference Ids of inserted in testsetup records

@isTest public with sharing class TestClass { public static Id userId; @TestSetup static void makeData(){ User u = createUser('userLastName'); insert u; userId = u....
0
votes
2answers
2k views

apex test public void - Non static method cannot be referenced from a static context

I have an apex class named votingRelationHandler. It is called from a trigger and works great but I am having issues with writing the test class. Issue in the Test Class: Non static method ...
0
votes
0answers
142 views

RecordType using Test.loadData in Testclass for account object

I am trying to export data in csv from one sandbox and trying to load the same data into Test class using loadData method. Currently , I am struggling in creating RecordType within Test class For ...
0
votes
1answer
317 views

Reporting on Advanced Content A/B Test blocks

I've set up some content items in Content Builder that use an A/B test content block. I'm testing two different images. How can I report on the performance of emails that use image A vs image B? Can ...
-1
votes
1answer
493 views

Add a picklist value to Global Value Set in test class

I am working on test class that inserts an Opportunity with the opportunity products using the correct price book/price book entry. The OpportunityLineItem has a ProductSelected__c picklist field. We ...
4
votes
2answers
2k views

How to use Stub API in the following scenario?

I am trying to understand Stub API a bit: My Class: public class DistributedMSelector { public static Map<string, user> getUserMap(Set<String> employeeIdSet){ Map<String,...
0
votes
1answer
794 views

In test class can see all org users in list

I have written one query in test class for fetching users,as per my understanding query should return the user records created in test class only,but its giving all user from salesforce org.is that ...
2
votes
0answers
68 views

Apex Batch Test - works if I populate only one account, fails in setup with 2 accounts

I have written my first Apex batch processing class. It works when I manually create records and run it in my sandbox. It is very simple. We've added a set of fields that can have up to 3 values: '...
0
votes
1answer
34 views

How to create records for Person Account related to another Person Account

All I want to make @TestSetup Method to make coverage for my trigger. I need to make two Person Account and one is related to another. My code like below: // Person Account Setup String ...
0
votes
2answers
369 views

How to test and assert email template?

I'm getting this error: System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-...
0
votes
1answer
61 views

How to cover piece of code using test class which is checking if its sandbox or Production

I have below Peice of code which is chekcing if its sandbox then run If part else run Else part if(runningInASandbox()) { return getSsoRedirect('one', startUrl, ...
1
vote
1answer
818 views

Does Marketing Cloud deduplicate subscribers before making an A/B split?

I am configuring my first A/B split test with an email. I know that during a single send to a data extension, normally, Marketing Cloud will dedupe the DE's contents on the email address. However, I'm ...
1
vote
1answer
511 views

Attempt to de-reference a null object when calling class method from Test class

I am trying to write a test method that calls a method in my class to get some configuration data. The method in my class returns a Map. From my test method, when I call the method in my class, I ...
-1
votes
1answer
296 views

How to cover the SETENDPOINT kind of lines in test class [duplicate]

**APEX-CLASS** public class TriggerFlodataWorkflowController { public string inputIds{get;set;} public List<String> selectedNames{get;set;} public List<String> selectedIds{get;set;} ...
0
votes
0answers
98 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. ...
0
votes
1answer
45 views

How to perform a load test on a triggered send

I'm looking to perform a load test on a triggered send by pushing ~160k records through the trigger. For the test, we are planning on taking a block of live records and replacing the email address ...
0
votes
2answers
2k views

How do I create multiple records in the test data factory of a salesforce test class?

I have something like this but I want more records of this object to be created to be used in my test class public static Lead createLead(Account new Account) { Lead newLead = new Lead(); ...
3
votes
2answers
96 views

'List has no rows for assignment to SObject' Mystery

I have the following test class: @isTest private class PMTools_AppliedTechExtensionTest { @TestSetup static void SetupTestData(){ Account testAccount = new Account( ...
2
votes
1answer
273 views

Test Lead has OwnerId but Cannot Access Owner Fields

I have the following test setup method: @TestSetup public static void testSetup() { //system.runAs(u) { //JITTriggerManagement.toggleTrigger('Lead'); Lead l = new Lead( ...
0
votes
0answers
245 views

Test Class - SOQL in Test Returns No Results using Database.Insert(RecordList,DML), but works using Database.Insert(RecordList)?

I am creating test coverage for a new Lead Process we've built for our company. To properly test this deployment, I need a list of Leads to show as being Inserted by our Pardot API connector user, and ...
0
votes
1answer
987 views

ERROR: No AuthInfo found for name [object Object]

Ad the title described, I have the following error: ERROR: No AuthInfo found for name [object Object]. What i did was to install a whole new clean visual studio code, with the related salesforce ...
0
votes
2answers
61 views

I have worked on the test class with 97% code coverage and now i would to try it with using @testsetup can any one please help me? [closed]

@istest(SeeAllData=false) public class Testclassforaddingpli { //public list<Proposal_Line_Item__c> prolist = new list<Proposal_Line_Item__c>(); @istest public static void ...
0
votes
2answers
482 views

Ant deployment doesn't recognize updated test classes and fails

I have a small set of lightning components and related apex classes that I'm trying to deploy using ant. The first deployment was fine. I had to make a change and updated the apex class that has all ...
4
votes
2answers
420 views

How is it possible for @TestSetup to effect test result?

While refactoring a test to make it more consistent with the style of our other tests, a colleague came upon something really weird. The original test created the test account in @TestSetup, like so: ...
2
votes
2answers
1k views

Accessing Variables from a Parent Class

I am attempting to set up tests for my APEX classes, more specifically, I am attempting to create a parent class that includes a prepareDatabase function that creates data for my tests, and this ...
0
votes
1answer
34 views

My Test Class Isn't Passing

I have a test class which is testing a controller but I cannot get the test to pass. Here is the controller class: //a controller class to get incidents for display on VF page and then //anonymise ...
0
votes
0answers
24 views

MIXED_DML @testSetup TestMethod [duplicate]

So I am seeing a very weird issue. I am getting a MIXED_DML error in one of my test methods. In the @testSetup annotated method, I am indeed perform a mixed dml transaction (shame on me). However, ...
1
vote
1answer
20 views

Can't get my test class to pass

I have a controller which I am trying to write a test class for: //a controller class to get incidents for display on VF page and then //anonymise the incidents and related contacts public class ...
0
votes
0answers
226 views

Hello i am not able to get the result from this test class [duplicate]

I am trying to update the email in my Test class but it is not happening please help me. This is my class- global class PrepareSandboxPostCopy_Batch implements Database.Batchable { String query; ...
2
votes
3answers
1k views

How do I pass record IDs from testSetup to isTest methods?

I want to create data in a test class that can be used by multiple test methods. However, for the test method to be able to access that test data, I need a way to pass the record IDs to from the @...