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
1 answer
33 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
421 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
61 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
63 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
95 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
51 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
132 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
48 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
76 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
  • 538
-3 votes
1 answer
52 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
31 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
40 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
54 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
188 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
  • 109
0 votes
0 answers
25 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
434 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
55 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
127 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,547
-5 votes
2 answers
87 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
78 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
73 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
594 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
  • 81
0 votes
0 answers
38 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
0 answers
45 views

Unable to create Feeditem for External Chatter User in test class

I am trying to create FeedItems on a CollaborationGroup as an external chatter user. Although the Group is public and Person is external user with Customer Community Plus Login license. An error is ...
AmanSharma's user avatar
0 votes
1 answer
75 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
186 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
39 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
0 answers
253 views

How can I test email invocations from batch Apex?

I have an Apex batch job and I am trying to test the sending of an error email. Here is a simplified version of the code: private Integer emailInvocations++; try { HttpResponse httpRes = http....
Luke Bray's user avatar
  • 506
0 votes
1 answer
41 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
192 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
66 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
107 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
86 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
347 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
57 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
242 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
163 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
62 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
239 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
59 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
96 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
796 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
2k 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
0 votes
1 answer
132 views

Test Data not being found when running a test

I'm writing a test class for a batch class, however I'm running into issues when it comes to the test data. Code more or less looks like this: @isTest public static void testMethod(){ Box__c b = ...
conejo's user avatar
  • 15
0 votes
1 answer
75 views

Apex test class for Standard Controller extensions - Test problem

:) I am writing test class for controller extensions, but I get the error: System.TypeException: Invalid conversion from runtime type Asset to Account. Can you please look at my code, and tell me what ...
ApexNewbie's user avatar
0 votes
1 answer
53 views

Code Coverage for custom setting

I am writing test class for the below method. But it is giving me error - List has no rows for assignment to SObject get{ if(PCAppSwitch__c.getInstance().Candidate_Record_Type_API_Name__c =...
goel123's user avatar
  • 15
0 votes
0 answers
222 views

How to cover for loop with wrapper class in test method?

I am not getting coverage from " for (FileInfoWrapper file : caseInfo.files)" @AuraEnabled public static String loadData(String strCaseInfo) { System.debug('caseInfo ' + strCaseInfo); ...
Raffus Kh's user avatar
1 vote
1 answer
237 views

Getting exception in Test Class

I'm getting exception in Test class Assertion failed. Test Class: @isTest (SeeAllData = False) public class OpportunityTriggerHandlerTest { @TestSetup public static void testDataCreation(...
Rose 's user avatar
  • 111
0 votes
1 answer
524 views

Is Test.isRunningTest() needed to prohibit an apex test from performing a callout even if you use Test.setMock()?

Taking into consideration the below pseudo code, do we need to check if an apex test is running before performing callout? Or does the Test.setMock() method automatically prevent callouts during a ...
parkerbbrown's user avatar
-2 votes
1 answer
2k views

Test Class for custom metadata

Getting the error of List has no row assignment in test class. How should i query the custom metadata in test class Apex - public with sharing class GetAccountsController { @AuraEnabled(cacheable=...
user111906's user avatar

1
2 3 4 5
11