Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs

Questions tagged [failing-tests]

A unit test is code that is written and executed to test a specific portion/unit of source code. Tests that do not pass are considered failing. Tests that do not generate desired coverage are still considered to pass.

Filter by
Sorted by
Tagged with
0 votes
0 answers
16 views

Is it possible to Approve a ProcessInstanceWorkitem as another user in a Test Class?

I'm trying to approve a ProcessInstanceWorkitem as its ActorId in a test class, but I'm receiving the following error: System.DmlException: Process failed. First exception on row 0; first error: ...
Cassio's user avatar
  • 3
0 votes
2 answers
34 views

Duplicate Error Message in Test Class not outputting ID - <unknown>

I in my Apex Class I have a catch in my update. If there is a Duplicate error I am searching the Error Message for the Id so that I can run an alternate process. This works fine when running against ...
Jeff Callahan's user avatar
1 vote
1 answer
41 views

Unable to lock row or deadlock issue

We have over 200 test methods in the org and since I started creating some test classes for my own Sandbox I have ran into issues with the following error but may vary by method: System.DmlException: ...
MrKnudz's user avatar
  • 13
2 votes
1 answer
71 views

OpportunityFieldHistory in Apex test class (field tracking - NewValue)

i'm new to learning about Apex Test Class. I have business logic that needs to check the value of 'OpportunityFieldHistory' == 'ClosedWon' in a class to create a record (Contract). I'm making a test ...
Aparicio Jr's user avatar
0 votes
1 answer
30 views

I trying to write test class for a Apex class. I covered the try statement where I couldn't cover the catch statement. Please help me to resolve

Main Class: public class PrintJobPDFController { @AuraEnabled public static List<String> getPDFprint(string recordId) { try{ System.debug('recordId'+recordId); ...
Arun Pandiyan's user avatar
0 votes
0 answers
35 views

Why does the content version insert fail in a test?

I have a method that takes a contentVersion where the data is stored locally and does a callout to transfer it to sharepoint creates a new ContentVersion with a link to the sharepoint file to replace ...
Andreas Tschritter's user avatar
0 votes
1 answer
104 views

Test Class Data Setup - Cant Access Data outside

Within my test class's "setup()" method, I am calling a class that creates and inserts Salesforce objects and the necessary related objects to create that object (if any). @TestSetup static ...
plowrey's user avatar
0 votes
1 answer
316 views

Error while creating a test class - DML operation Insert not allowed on Survey [duplicate]

I have created a apex batch class to create survey invitations, subject records & send the unique survey links to participants. Trying to write a test class to cover it by inserting a surveybut ...
SMorse's user avatar
  • 39
2 votes
0 answers
145 views

Flow triggered from Apex Test throwing error: DUPLICATE_VALUE: duplicate value found: <unknown> duplicates value on record with id: <unknown>

What happened: I have a test method calls a method in a class that ultimately inserts a new record for ContactRelation__c object. Background: The ContactRelation__c object has a field called "...
dale's user avatar
  • 121
0 votes
1 answer
41 views

force:apex:test:run throws error in CI: "No tests were able to be executed on the org. Please verify that the source code has been pushed correctly"

Upon attempting to run Apex tests via CI using command "force:apex:test:run" in a packaging org, I get the following error: "An unknown exception occurred. No tests were able to be ...
Andrei Migachev's user avatar
2 votes
1 answer
488 views

Test class in managed package is failing with Internal Salesforce Error: 415122577-6508 (-1655455180) (-1655455180)

When Managed package metadata is deployed to a scratch org and tests are run by automated pipeline, one of the test method in a test class is failing with following error "Internal Salesforce ...
Vasudev Pai's user avatar
0 votes
1 answer
89 views

Custom Object Field Name Values Are Not Stored or Not Available As Referenced Data in Lookup?

We have three custom/standard objects (Opportunity, Package__c, Economics__c) referencing somehow Plant__c. Upon creation of Plant__c, public static Plant__c createTerminal(String country){ Plant__c ...
Arvin's user avatar
  • 3
0 votes
0 answers
123 views

Test.startTest and Test.stopTest affecting RestContext

I have a very weird issue related to an Apex RestResource that I can't seem to wrap my head around. I have an Apex class defined as a RestResource and am trying to test the functionality. In one ...
Antonio Manente's user avatar
0 votes
1 answer
253 views

System.DmlException: ConvertLead failed. First exception on row 0; first error: RECORD_IN_USE_BY_WORKFLOW

I am trying to convert a Lead in a Test Class but i'm facing the exception above. I searched about this error but it's didn't helpfull. I try to follow these steps to search for a solution: https://...
Erick Petzold's user avatar
1 vote
1 answer
152 views

Troubleshoot Test Class for Schedulable Apex with Email Message

My schedulable apex is working properly and I have 100% test coverage on it, but the test is not giving me the System Assert I am expecting and I'm hoping someone can spot the reason why. The Apex ...
Kendra Broom's user avatar
0 votes
1 answer
816 views

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Owner ID: owner cannot be blank: [OwnerId]

I wanted to write test class for Triger which insert contact on user Insertion. So I am writing test class to check whether new created contact is related to that user or not but Im receiving error. ...
Sajid's user avatar
  • 13
0 votes
0 answers
78 views

Test Service Report Creation

I made a trigger on Service Report and I'm trying to write a test class for it, but I get this error every time I try to insert a Service Report in a test function or my makeData function: System....
Rostyslav Popov's user avatar
1 vote
1 answer
273 views

Unable to query PricebookEntry in ApexTest Class

I am writting Apex Test Class, but facing the issue, of unable to query PricebookEntry. Actual Error: (System.QueryException: List has no rows for assignment to SObject) Here's the logic in a ...
prem22's user avatar
  • 652
-3 votes
1 answer
77 views

Apex test class not working and fails

I have the following apex class: public with sharing class TT_DisplayRelatedOpportunities { @AuraEnabled(cacheable=true) public static List<Opportunity> getOppList(String recordId) {...
Marjan's user avatar
  • 15
-1 votes
1 answer
37 views

Getting Error in This Test Class

@isTest private class LeadUpdateTriggerHandlerTest { @isTest static void testHandleUpdate() { // Create test data Lead testLead = new Lead(FirstName = 'Test'...
user131546's user avatar
0 votes
1 answer
108 views

MIXED_DML_OPERATION, DML operation on setup object

My Apex Class public with sharing class WeekendTimeSheetAlerts implements Database.Batchable<sObject>{ final String weekToSubmit; final String query; final Date weekMondayDate; ...
YETURU CHENCHU's user avatar
0 votes
0 answers
60 views

A test class fails : Formulas don't return any value when multiple test methods run on Dev Console

Apex Test Class Setting The class is marked as @isTest(isParallel=false). All the methods are static. Apex Class & Formula Setting The handler class is processed after insert. The formulas return ...
saho's user avatar
  • 1
0 votes
1 answer
593 views

Getting System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Enter a role-based external user

Im trying to create a record of an Object (DelegatedAccount) in a Test class inside the test Setup method. Its an entity that has 2 Lookups - To Account and User Object. while creating the User record ...
Amax1's user avatar
  • 121
0 votes
0 answers
28 views

Note Test Method Issue

I created an apex method that checks if the content of a Note is lower than 10 characters. I have some problems with the test method and i can't make it work. I get an assertion failed on this test: '...
Artur's user avatar
  • 9
1 vote
1 answer
953 views

System.JSONException: Unexpected character ('S' (code 83))

I am trying to write a test class for my rest resource and I keep getting a failure with the above error message. I've seen other anwsers suggest that there may be a '' escape character in the text, ...
Ryan Neel's user avatar
0 votes
0 answers
69 views

schedulable class shows 0% coverage while trying to deploy to Production

I have a Schedulable class which calls a Batch class, I have enough coverage when checking in sandbox, But when trying to deploy to production Scheduler class shows 0% and Batch class shows 60%. I am ...
sangeetha balasubramanian's user avatar
3 votes
1 answer
193 views

How Do We Test PostInstall Script That Makes PermissionSetAssignment?

I'm missing something obvious but we have a PostInstall script that makes a PermissionSetAssignment to the installer to give an Admin permission. The test class is failing since, as is documented in ...
ddeve's user avatar
  • 1,606
-5 votes
2 answers
116 views

System.NullPointerException: Attempt to de-reference a null object on test class

I have getting error as System.NullPointerException: Attempt to de-reference a null object on the test class Class:- /* * @Class Description- Contact Trigger Helper. * Class is introduced to handle ...
user68781's user avatar
0 votes
1 answer
146 views

Unit testing nested asynchronous jobs

I'm trying to make my tests pass but I can't. I have My Queueable Class: public class MyQueueable implements Queueable, Database.AllowsCallouts { public MyQueueable() {} public static void ...
FarKorE's user avatar
  • 25
0 votes
0 answers
94 views

Erro "Os métodos definidos como TestMethod não suportam callouts para serviços da Web" ao implantar classe/trigger

Olá! Estou com problema ao implantar em produção uma trigger que foi atualizada, e ao executar o teste obtenho o erro a seguir em dois métodos que não possuem qualquer integração. "Os métodos ...
Camila Roque's user avatar
0 votes
1 answer
1k views

AssertEquals not working as expected

I have a test class that works on my org dev, I'm trying to make deploy in another org but it's having a strange behavior, the error is in the first assertEqual: @isTest static void testUserStore()...
Alexia's user avatar
  • 83
0 votes
0 answers
46 views

Apex Failed Test Run: Method does not exist or incorrect signature

I have a class with the function: public static void updateTargetAmount(Id targetId, String customFieldApiName){...} In my Testclass i handover the 2 parameters: TargetHelper.updateTargetAmount(...
Benjamin's user avatar
0 votes
1 answer
109 views

MileStoneUtils apex class requires code coverage. Stops at 57% [duplicate]

Working off of the code provided here https://help.salesforce.com/s/articleView?id=sf.entitlements_milestones_trigger.htm&type=5 The test class does not cover required coverage specially the if ...
Abhinandana 's user avatar
0 votes
2 answers
252 views

Apex test class method not working

I have the following method in my apex class: @testVisible private static Custon_Object_Case__c getExistingRecord(Messaging.InboundEmail email){ List<String> referenceId = email.references; ...
Marjan's user avatar
  • 15
0 votes
0 answers
43 views

How do I test child accounts? Test code shows nothing for child accounts ANSWERED

How do I test child Accounts? The test I've written finds the parent account, but returns nothing from the child query. Work: Display a button if the Account has a set of fields properly populated, OR ...
afandre's user avatar
  • 71
0 votes
1 answer
61 views

How can I create test class to use the hyperlink field?

I have a custom object with formula field using hyperlink function. However I need to create a scenario in apex test class where a formula field (using HYPERLINK formula) is click. Example of a ...
user11880836's user avatar
-1 votes
1 answer
265 views

Could we make Mandatory Field null in test class?

I have custom object ABC__c . i have mandatory custom field Account__c on this object which is a master detail. Can we make this fields as null in a test class?
Saurabh Kumar's user avatar
0 votes
1 answer
104 views

Asking for License to assign a permission set to a user in test class

Hi all i am assigning a permission set to a user below the code " public static void assignPermissionSetsToUser(Id userId, Set<String> permissionSets) { List<...
Vishal's user avatar
  • 1
3 votes
1 answer
110 views

Static flag being ignored in tests since Spring 23 Release

As of Spring 23, several tests where we publish platform events started failing. We use a static flag as a condition to execute a code block and looks like now the line where the flag is being set is ...
user127426's user avatar
0 votes
1 answer
146 views

Test class for records owned by System User

I have batch job class which fetches ServiceAppointment where Owner.Name = 'System User' in it's Database.QueryLocator start method. global class CancelDuplicateSaBatchClass implements Database....
Ravi's user avatar
  • 1
0 votes
0 answers
531 views

Test class and code coverage for FSL ServiceAppointment

I have below class for which I am writing test class. global class FSL_ScheduleSABatch implements Schedulable, Database.Batchable<sObject>, Database.AllowsCallouts, Database.Stateful { global ...
Ravi's user avatar
  • 1
0 votes
1 answer
179 views

Working Apex test class no longer works after being deployed

Well, I'm confused. A few months ago, I got a working apex class and test class configured to generate a Quote PDF document and email it. I had 99% code coverage and deployed it. I went back to modify ...
Travis's user avatar
  • 1
1 vote
2 answers
344 views

In writing test class, what's the difference between calling the method directly or using DML statement?

I wrote a trigger to prevent the deletion of a record. And also I'm writing test class. public class ClassA public static void preventDelete(List<Person__c> pers) { for(...
user11880836's user avatar
3 votes
1 answer
247 views

Campaign Member Statuses not Automatically Created in Test Classes

If I create a new Campaign through the Salesforce UI, the Campaign Member Statuses of Sent and Responded are created automatically. But when I insert a Campaign in a test class no Campaign Member ...
windman's user avatar
  • 43
-1 votes
1 answer
67 views

Schedulable single email apex class low coverage when deployed to production

I have a schedulable email apex class that sends email to sales rep with opportunities with awaiting approval as stage. This partial apex class below is 100% covered in production, however when I ...
Jayson's user avatar
  • 3
0 votes
1 answer
328 views

Creating attachment csv for visualforcepage in a test class

I created a VisualForce page to process CSV files for people to create leads. For some reason when I go to call the method for my test class to read the CSV file I am getting the error Non static ...
Josh Anderson's user avatar
-1 votes
2 answers
70 views

Coverage Code always 0%

I tried this Test Class for my trigger but I always have 0% as coverage , some help please => Trigger trigger AfterUpdate on OBJ__c (after update) { Id currentUser = UserInfo.getUserId(); ...
Salesforce dev98908's user avatar
-3 votes
1 answer
145 views

Methods defined as TestMethod do not support Web service callouts? [duplicate]

public class QbPaymentConnect { @future(callout=true) public static void QbCustomers(string recordId){ opportunity op = [select name from opportunity where id=:recordId]; ...
Dashrath Singh's user avatar
1 vote
1 answer
1k views

Assign Custom Permission in Test class

I have a validation rule AND( ISPICKVAL(Submission_Handover_Process_Status__c, 'Awaiting Validation'), ISCHANGED(Submission_Handover_Process_Status__c), NOT($Permission.Submission_Handover)...
Salman Khan's user avatar
0 votes
2 answers
3k views

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

I'm getting the below error while running the test class. Can anyone help on this please? Error : System.DmlException: Insert failed. First exception on row 0 with id a057h000002BqVUAA0; first error: ...
user avatar

1
2 3 4 5
11