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
1
vote
0answers
28 views

Unaltered Test passes in Sandbox AND Production, but fails during unrelated deployment validation

I am trying to deploy a few classes. I've got a Sandbox that I literally created this morning off of Production. Nothing is different between the two except the 3 classes I'm deploying. How can it ...
4
votes
1answer
102 views

Why won't Apex IF statement work in Production Unit Testing after working in sandbox?

this is driving me NUTS and any thoughts are MUCH appreciated after looking at this for far too long. Use case: users in certain profiles need to be automatically added/removed from a particular ...
1
vote
1answer
31 views

How to test a change OwnerId by groupQueue.Id?

I have a trigger. If a user who creates a record isn't 'Manager' (UserRole.Name) - record's OwnerId change to GroupQueue.Id. I have a correct test method for scenario, where user-creator is 'Manager', ...
0
votes
2answers
30 views

Test Coverage Help - Insert Custom Object But No Test Coverage

Hopefully this will be an easy one and I am just missing something small. I have a method queries for a custom object. My test class isn't seeing the custom object I have created in the test class. ...
0
votes
1answer
27 views

Trigger Test Class failing assertion

For the following class, I have a test class with two methods. The second method is failing at System.assert(Jet2.Status__c == 'Booked'). The status is still 'Active.' How do I fix this? Trigger ...
4
votes
1answer
2k views

What should the negative tests include?

While preparing myself to the Developer 1 certification I met the following question: A developer is asked to write negative tests as part of the unit testing for a method that calculates a person's ...
0
votes
1answer
285 views

assertEquals | All Object Properties Are the Same but the Assertion Fails

In my tests I create an object and compare it to the one returned in the function using System.assertEquals. Despite all the properties being exactly the same I still get the "Assertion Failed" ...
1
vote
1answer
27 views

Case Number duplicates found for case insert in Test Class

I faced a weird scenario today. I have a @testSetup method for inserting my case records and then used another method to query those case records to fetch CaseNumber field and pass it to a JSON String ...
0
votes
1answer
331 views

How to cover the below lines in my test class code coverage?

Can someone please help me how can I get the code coverage for below line: Test class code: @istest public class Testownerassisgnbasedonaccount { @isTest static void ...
4
votes
2answers
965 views

How do I create Test Data for an Org. Wide Email Address?

I need to create an Org. Wide Email address for my Test Class, and I can't seem to find documentation for this. One forum led me to believe it wasn't possible, but it wasn't clear if I was ...
-3
votes
1answer
52 views

Test class failing for striphtml method

I need some help with test class which is failing.Here is my code trigger striptext on customobj__c (before insert, before update) { for customobj__c atxt:trigger.new) { if (atxt.Record_Type_Name__c ...
1
vote
4answers
80 views

No Code Coverage

I am working on an Org with some old code that is beyond my admin / learing Apex ability to fix. This trigger is throwing errors for two many future calls and it no long serves any purpose in our Org. ...
0
votes
1answer
53 views

How can I get code coverage for a constructor method in a StandardSet controller?

I am struggling hard to get code coverage for following constructor method with some URL method usage. Basically the filter name I am trying to fetch is the list view ID (also need some insights to ...
0
votes
1answer
45 views

Test Coverage for Current Page Id

not sure what I am doing wrong here with setting the page id in the test class. Can anyone see what I am doing wrong? The failed test is throwing System.NullPointerException: Argument 1 cannot be null ...
0
votes
1answer
94 views

Test failure 7% for HTTP Call out [closed]

I am not sure why I am getting the two errors I labeled below during the http send in the first class or in the Mock Impl class when I assert the endpoint. public class ProcessHandlerShowAccounts { ...
2
votes
2answers
247 views

Field appearing NULL in tests

I have a helper class that is working as intended while testing manually but in tests it is failing. I am trying to test the following method: public class helper { @TestVisible private ...
2
votes
1answer
2k views

regarding External entry point

i have one custom field called Unique_Vendor_Id__c on account object (external id checkbox checked) and its auto-number. now in test class when i create account for test data Unique_Vendor_Id__c ...
1
vote
1answer
536 views

Empty picklist value is getting saved as null

I am trying test a piece of code by changing a Status__c field on Save_Attempt__c Object. I am explicitly setting the value of Status picklist to an empty string and not null but when I query, it's ...
3
votes
2answers
942 views

Platform Event Testing: Unexpected Exception: Error processing messages

I've been doing a lot of work with Platform events and found it a fantastic way to implement some domain driven design patterns, decouple code, and separate execution contexts. Unfortunately I've been ...
0
votes
2answers
926 views

Test class coverage for custom label

I have the following code where the intent is to log the details of the object only when the value of the custom label is true. This way I can control enabling logs from custom label settings. I do ...
0
votes
2answers
82 views

Unable to cover few lines in Test class

Apex Controller: public class Controller{ @AuraEnabled public static string createTask(String BankID){ List<Bank__c> ls = new List<Bank__c>(); System.debug('>>>'+...
0
votes
2answers
58 views

Attempt to de-reference a null object when traversing DescribeSObjectResult to check permissions

I have this method that checks a user's write permissions on an Apex controller. It works just fine at runtime. However, I'm writing a test to cover it (indirectly) and I'm getting a 'Attempt to de-...
1
vote
1answer
243 views

How to write test cases for Dynamic picklist

I have a dynamic picklist that I am displaying on the visualforce page. Here is my visualforce code: <apex:selectList value="{!SelectedNomination}" size="1" id="a"> <apex:selectOptions ...
0
votes
1answer
105 views

Basic Mock Test Coverage Help

I think this will be a easy fix, I am sure it is something I am just overlooking at the end of the day. I created a mock class to test my callouts. It is called SingleRequestMockClass.cls, I got the ...
-4
votes
1answer
58 views

Apex Test Code Coverage Issue for Aggregate Functions

I have 2 objects Order and Shipment__c. For each Order we can have Multiple shipments and I'm trying to update the Order with MAX(ship Date) from all related shipment records. The trigger and helper ...
0
votes
1answer
41 views

Test Method for Case Insert from Trigger

I have a trigger that fires when an Opportunity is Closed Won, has OpportunityLineItems and those OppLineItems relate to a specific Product. The firing of the trigger creates a Case Record based on ...
0
votes
2answers
66 views

Error with Apex callout

I'm trying to connect to a web portal via API's. HttpRequest httpRequest = new HttpRequest(); httpRequest.setEndpoint('xxxxxxxxxxxxxxxxxxxxxxxx'); String body='account=xxxx&authenticationkey=...
4
votes
0answers
176 views

Intermittent Process Builder Flow Error - How to troubleshoot with no info?

Background I'm getting a dreaded flow error for one of our test methods that occurs fairly regularly, but not consistently. I've reviewed the debug logs thoroughly, but can't see any obvious way to ...
1
vote
1answer
85 views

@HttpPost test will not run - Method does not exist or incorrect signature: void doPost(String,

Just started with Apex last week so very new. Building a @RestResource to pick up webhooks sent from an external DB. Code has been tested and working as expected in Sandbox. Can not get the unit ...
0
votes
1answer
555 views

Insert failed. First exception on row 0; first error: PORTAL_USER_ALREADY_EXISTS_FOR_CONTACT, portal user already exists for contact: []

I am trying to insert portal user records and receiving this error System.DmlException: Insert failed. First exception on row 0; first error: PORTAL_USER_ALREADY_EXISTS_FOR_CONTACT, portal user ...
5
votes
2answers
300 views

Why is my After Delete Trigger test class failing?

I have a trigger set up on the Account object for After Delete. We have an Affiliates table that has a lookup field to Account. If an Account is merged, I don't want to delete an Affiliate. It will ...
5
votes
1answer
275 views

Is it normal to tests not be able to create queues because there's one with the same name on the organization?

If I have, for example, in production a MyQueue queue, with the same DeveloperName, and I'm trying to run a test class to deploy a change set, which contains a test that inserts a MyQueue queue as ...
0
votes
0answers
109 views

Force calculation of Cross Object formula to be used in test class

The basic gist of my issue is that I have a batch apex class that uses cross object formulas in some IF statements (Something like Contact.Account.FirstName). The problem is that when I create the ...
6
votes
0answers
134 views

Why inserting a user object and making callout in a test throws CalloutException in Production?

I stumbled upon strange behavior when executing tests on deployment to production organization. In the test, I first insert a User object, some other objects and then as the last one, a CampaignMember ...
2
votes
1answer
35 views

Custom Object Relationship query behaves differently in Test from Execute Anonymous

Background I have a custom object Contact_Coverage__c. I have a custom field Contact_Coverage__c added to the Activity standard object, with the child relationship name Activities__r. In general, I ...
0
votes
1answer
35 views

I cannot delete a contact due to “System.NullPointerException: Attempt to de-reference a null object”

I have this trigger: trigger deleteContactReceiver on Contact (before delete) { List<Contact> con=Trigger.new; GDPRContact.deleteContactURN(con); } Invokes: public static void ...
2
votes
2answers
466 views

Sudden MIXED_DML_OPERATION errors without code changes

So I have 3 orgs that are basically all on the same codebase. On the production org (the one that gets changed the least) some of the tests are suddenly failing - all with the same error message: ...
1
vote
0answers
182 views

Apex test classes fail on HTTPResponse

I have some test classes that run decently until they hit something like HTTResponse res = h.send(req); Where I then get 'System.UnexpectedException: Script-thrown exception'. I make a few ...
0
votes
2answers
248 views

Test class error on validation : A flow trigger failed to execute the flow with version ID

I am getting an error when trying to do a validation on a changeset on production. The error that I receive is as below. System.DmlException: Insert failed. First exception on row 0; first error: ...
0
votes
1answer
38 views

production is generating more records in test class, causing failed validation

I created a Lightning Component Controller. It's suppose to clone our custom object pba__Offer__c. In our staging environment, I've managed to get 97% code coverage, and all my asserts pass. Class ...
0
votes
1answer
346 views

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION

I wrote the validation rule to restrict the custom field picklist value it many test classes is getting failed because of that where and what line i can add into picklist value to cover the test ...
1
vote
0answers
227 views

How can I view my test classes debug logs of an ant deploy

I have about 20 classes that I deploy to production via ant. Some of my test classes fail. I want to view the debug logs but I cannot find the way to look at the logs of my ant deployment. Any help ...
-1
votes
2answers
600 views

Deployment failing validation only when two test classes are run

I am trying to deploy a change set which includes to classes and a test class. For validation I am only running two test classes, one which is included in the set and one which is already in ...
3
votes
1answer
2k views

Test.setMock not working in Apex test

I am trying to test the server side Controller in Apex test. The controller makes a call out to get account information and returns the response in an Object format to lightning component. The ...
0
votes
0answers
21 views

Can not reproduce behavior within testcase: Duplicate accounts after merge

I'm sorry for the vague description in the header. So here's my problem in detail: I have an automation, that essentially checks a "potential" child record (not master-detail, just lookup) of accounts,...
0
votes
1answer
94 views

Need to have a workaround for calling a visualforce page whose controller calls a WebService Callout

I am having a custom button on my custom object, which calls a visualforce page by passing the record Id from which it was called. The controller for this Visualforce page is making a WebService ...
0
votes
1answer
71 views

Facing Attempt to de reference null object in test class code coverage

Hi We have a apex class and trying to write Apex class for the code coverage. For some reason the Test class wont pass. Please advise on this Iam getting Attempt to de reference error. Please find ...
0
votes
0answers
83 views

Method being called inside a test method returning null reference

I am calling a method to validate passwords in an apex controller which is working by returning either true, false, or null @TestVisible static Boolean validatePassword(){ if (string.valueof(...
0
votes
2answers
168 views

Test Error & Trigger Null Pointer Exception

I'm attempting to build a trigger that pulls the FullPhotoUrl from the User profile and set a field (FullPhotoUrl__c) on the SFDC_Employee__c object to the url. Here's the error I'm getting I'll paste ...
-1
votes
1answer
361 views

test method fails for execute function in scheduler batch class

I have the following Execute method and want to test it.The test method throws the exception of invalid email, not understanding how can I do it. Also, how can I test the opportunity Code? //Batch ...