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
-2
votes
0answers
46 views

Apex Test Class Failing - Fields Not writeable

Here is my Apex Class: public with Sharing class abcService{ @AuraEnabled public static List<customObject> xyzMethod(){ UserAppInfo userAppInfo = [SELECT Id, AppDefinitionId FROM ...
0
votes
1answer
42 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 ...
1
vote
0answers
17 views

CircleCI, re-run tests that failed in parallel mode during build

note: I'm stuck in an org-centric world, so CircleCI is setup w/my dev sandbox, not scratch orgs. Recently, I set up a CircleCI build to run my sandbox orgs tests w/RunLocalTests on each pull request. ...
2
votes
1answer
35 views

Test Class with HttpMockCallout is throwing error

I am trying todo the Super Badge for the Data Integration Specialist. I wrote the Apexcall that will connect to the external system and send out the opportunity information. When trying to write the ...
1
vote
0answers
55 views

System.SObjectException: Field is not writeable: [duplicate]

We have the following code and Apex Test Class, and for some reason during Apex Test Execution (Developer Console-->Run Test) it is throwing the following error message below. Any ideas why the ...
1
vote
1answer
25 views

how to return the result of a method?

i'm working on a test class and its giving a false positive. i wish to assert the result of the method being tested to see what the failure message is. my test class ends with this Test.startTest(); ...
1
vote
1answer
29 views

sfdx force:apex:test:report is generating false PassRate as 100% though Failures present in the report

I have tried to run the apex tests and generate the test report on source deployed scratchOrg. report is showing Failure's count as 4 and Outcome as 'Failed' too, still shows the PassRate as 100%. ...
0
votes
1answer
21 views

Attempt to de-reference a null Object Email Service Test Class

I'm trying to build a test class for me to move an Email Service class into Prod, but I'm getting this error. Here is part of my code (The important bits) Email Service Class global class ...
0
votes
2answers
24 views

test class error : Method does not exist or incorrect signature

public class MyController { @AuraEnabled public static Account getAccount(String accId){ Account acc = [SELECT Id,Name FROM Account WHERE Id =: accId]; return acc; } } @...
1
vote
1answer
28 views

INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id] Error When Running Test Class

I've been trying to run my test class via Visual Studio Code, but I get the following error message: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id] Deployment to org is ...
0
votes
1answer
34 views

Test Class Coverage for Scheduled and Batch Classes

I am attempting to test a scheduled class that calls a batch class to update records. The following test class does not seem to find the Opportunity being created in the test class to pass that list ...
0
votes
0answers
22 views

How can I find out what “uncommitted work” is allegedly pending?

I have two schedulable batch processes, identical in every way except one is for Opportunity and the other is for Appointment__c. In real life, both batch processes work exactly as expected, which is ...
0
votes
1answer
48 views

Error: MIXED_DML_OPERATION Very Confused

I'm very confused about MIXED_DML_OPERATIONerror. Following test case fails in production but passes in uat. @IsTest private class MyControllerTest { private static final String USERNAME ='test@...
-3
votes
1answer
36 views

Test coverage help [duplicate]

One of my customer created below class. I have created a test class to cover but I am unable to cover the code. It seems I have created a correct data but it is not covering .Please anyone help me on ...
0
votes
1answer
29 views

Methods defined as TestMethod do not support Web service callouts error

This is my controller class. public with sharing class RSLeadReportcontroller { public List<RSLeadReport> ConsoleWrapperList{get;set;} public List<RSLeadReport> ...
0
votes
0answers
49 views

When will sending email through Apex automatically cause the test to fail, or when will it pass?

Normally, I expect tests to fail if the org does not allow email deliverability. In my current sandbox, I have several tests that fail because email is not deliverable. I think most of them fail at ...
1
vote
0answers
71 views

MIXED_DML_OPERATION Error in Test Case with S2XUserMap

Before starting, I know about DML operations and the order they should be performed in for test cases. Please do not comment on that. These test cases succeed and have been succeeding in partial and ...
0
votes
1answer
39 views

Update own User in apex class [closed]

how may I update own user profile? I have below code I need update user field of runAs user @isTest static void xyzMethod() { Boolean errofFlag= true; User userXYZ= createUserWithProfile('...
4
votes
2answers
679 views

'Guest users cannot be record owners' error during deployment of test class to production

I have increased test coverage of a class in QA Sandbox and I am trying to deploy that test class to production. When I run the test class in QA Sandbox, there is no error. But when I am deploying it ...
0
votes
2answers
42 views

Rest API Test Class Problem

I am having some problem while testing my rest API Class. My main class is as mentioned there @RestResource(urlMapping='/ONB2__Subscription__c/*') global with sharing class SubsRecord { @HttpGet ...
0
votes
0answers
13 views

Test succeeds in packaging org, but fails during packaging

We are trying to avoid using globalDescribe as that can eat a ton of time in larger orgs. So we are trying Type.forName to get SObjectType and their describes without hitting the costly global ...
0
votes
2answers
37 views

Apex Test Class Error on FinancialForce Sales Order Object

I've been trying for a few days to get this to work and but I've run out of ideas. I'm stuck. I can't get this test class to work. I get the following error. Trigger trigger efs_Sales_OrderTrigger on ...
0
votes
1answer
27 views

System.assertequal fails but debug log shows id

I have a test class that keeps failing on the last assert. The debug shows the newly created system record so not sure why it keeps failing. Location_c location = new Location_c( Name = '...
0
votes
1answer
47 views

After Update Test Class Is Not Committing Change

I'm working on a test class for an after update trigger and I am running into an issue where the change that is being done is not being comitted by the DML operation. For example, if I look at the log ...
1
vote
1answer
133 views

SFDX Test Cases Failing only on Package Version Create

EDIT: If you are using a CI flow, ensure that it isn't creating profiles for you when running test cases. That was the main issue for me when using cumulusci. I am trying to deploy a package version ...
14
votes
2answers
692 views

Salesforce 2020 release has blocked all Apex tests that use http mocking

We have 100+ tests failing now that our main testing sandbox has received the 2020 release. We can no longer deploy. We're getting many errors like Unexpected error: You have uncommitted work ...
0
votes
0answers
41 views

Confounded by Test Class Failing in Production but Passing in all Identical Sandboxes

I finally have to ask some other folks about this one. There's a test class from an (awful) unmanaged package in our org, and it has been there for a year and never been a problem, but suddenly it is ...
0
votes
1answer
26 views

Test class for updated field value

I have a class that is scheduled using CRON. I have created a test class and the test for the CRON is tested ok. However, the field update is not being tested and I cannot see why. Coverage is 57% ...
0
votes
1answer
80 views

How to create Case with Person Account in test class

@isTest public class TestDataFactory { public static List<Account> createPersonAccount(Integer numOfAccounts){ Id prsnAccountRecTypeId = Schema.SObjectType.Account....
0
votes
1answer
95 views

Assertion in the Test Class for ApexRest

I have a Apex Class which is exposed as a Rest API, the method is current void like below @RestResource(urlMapping='/SFDataAPI/*') global with sharing class SFDataAPI { @HttpGet global ...
0
votes
1answer
52 views

Date literals returning nothing in Apex Test

I'm doing the following in a test class. First inserting one record and then doing a record count to see that there is still only the one record in the DB. However when the query runs I get 0 records ...
-2
votes
1answer
81 views

Test Class to execute catch blocks [duplicate]

I have a Apex Class like below for handling the exception public class updateCaseRecord { @AuraEnabled public static void updateCheck(String caseId, String Status){ String msg = ...
0
votes
1answer
45 views

Testing chained continuations

Im wondering if anyone has figured out a way to test chained continuations? I followed the documentation for how to essentially make two asynchronous callouts in a synchronous pattern. I can test the ...
1
vote
2answers
27 views

You have uncommitted work pending error

I am getting a "you have uncommitted work pending" error on a test. Normally this is caused by a DML statement before a callout. That shouldn't be the case here. However, the code runs fine and I am ...
1
vote
2answers
330 views

Test Class for the Apex Class with try Catch block fails

I am trying to write a test class for the Apex Class with try - catch block and this is my first time coding test classes. The Apex Class is like below which has trycatch public class ...
-1
votes
1answer
25 views

Test Class for adding error message [duplicate]

@isTest public class ConvertTestClass { public static testMethod void test1() { Lead__c ld = new Lead__c (); ld.First_Name__c = 'Test'; ld.Name ='first'; ld....
0
votes
1answer
26 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
0answers
10 views

I need help for Test Apex class [duplicate]

I got 52% with this test code, Please give me some advice to improve the percentage for passing. @isTest global class BLmainMock implements HttpCalloutMock { global HTTPResponse respond(...
0
votes
0answers
51 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
0answers
59 views

Mixed DML causing test classes to fail to to Process builder

I have a Test class which was working fine but after a new process builder was created on user object to update a custom field created on user object, it started failing. In my test class code I am ...
0
votes
1answer
21 views

Batch callout error: Call out made it firstbefore DML

I have review similar questions, and all of them mention to do API before any DML similar question 1 and similar question 2 However, I am trying to do the API in the excecute, and I am still getting ...
0
votes
0answers
60 views

I don't know how to get 100% code coverage of this code

This code is used to prevent a case from being closed when it still has open tasks. When the user tries to close a case with an open task an error message pops up. Instead of using a Status from the "...
-1
votes
1answer
22 views

Help on System.ListException: List index out of bounds: 0 Error

I'm trying to write test code for my custom controller and got a new error that I haven't gotten before. My research so far has told me that misallocated and/or coming up NULL. Apex Class: ...
0
votes
1answer
44 views

SOQL injection issue on source scanner report

I am getting SOQL injection vulnerability on source scanner report. Please check one of the issue below. I tried string.escapeSingleQuotes() on query string. It is helping with removing this issue in ...
0
votes
0answers
27 views

Getting INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY when mocking an Object using Stub API

I am mocking a routing rule object by using the JSON list below that has an ID of type Routing_Rule__c. The Test is about creating some rules and setting some flags that would cause the lead object to ...
0
votes
1answer
36 views

Workflow Task Error When Trying to Deactivate a User from a SandboxPostCopy Apex Test

I'm trying to deactivate a user in an apex test. But am getting an error that the user (that I just created in the test) in being used by workflow tasks. The class implements SandboxPostCopy and is to ...
0
votes
0answers
55 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 ...
5
votes
0answers
84 views

Test fails with runAs, queueable and callout in specific org

Has anyone got an idea what could cause the following test to fail in one org and pass in another? The error is System.CalloutException: You have uncommitted work pending. Please commit or rollback ...
-2
votes
1answer
31 views

Error while saving a Test class

I have tried to insert session, speaker and session Speaker object in test class and I am getting error as "Unexpected token 'static'", Unexpected token 'testmethod', Variable does not exist: ...
2
votes
0answers
76 views

Apex test class enable product scheduling

Test Class Error: System.DmlException: Upsert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: unknown (scheduling not enabled on product): [...

1
2 3 4 5
9