Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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
1answer
140 views

Apex tests cannot be enqueued during a test ERROR

Below is the excpetion, System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Apex tests cannot be enqueued during a test. It happens ...
0
votes
1answer
47 views

Test class for Vf page controller failing

I've two vf pages QRCase (output) and QRCaseEdit(input/Edit) which are used to create cases for a specific record type 'Quality Report Case'. I tried writing the test class for controller, but it's ...
0
votes
1answer
259 views

Testing Error System seems to not recognize test class

ERROR: Unable to run tests synchronously: [This class name's value is invalid: Opportunity_EmailServiceTest. Provide the name of an Apex class that has test methods.]. @isTest private class ...
3
votes
1answer
174 views

Test classes pass in validation before deploy, but fail when i run them from “Apex Test Execution”

I have a few apex test class, that pass when i run them while deploying a change set, but when i run them from the setup, in "Apex Test Execution", they fail with the error MIXED_DML_OPERATION (the ...
2
votes
0answers
47 views

Test Class coverage error [duplicate]

I'm trying to deploy a Controller, VF Page, and Test Class into Production, but keep getting an error that my Code Coverage is under 75% in Production - even though the Code Coverage is over 90% in ...
0
votes
1answer
24 views

How to test 'throw new MyException()' in HttpResponse Callout?

I always get an Fail when try to test the negative scenario. How can I fix it? Sorry, I'm just learning. Callout: public class MyException extends Exception {} public class Token{ public String ...
0
votes
1answer
37 views

How can I test my Web Token and posted record from Post Callout?

I try to use HttpCalloutMock to test my post callout. But I become System.NullPointerException: Attempt to de-reference a null object. I need to test and web token, and posted object. I'm just ...
-1
votes
1answer
596 views

How to fix Attempt to de-reference a null object in test for Post Callout?

I become an error System.NullPointerException: Attempt to de-reference a null object in my test: public class Token{ public String accessToken{get;set;} } public static String accessTokenBody(){ ...
1
vote
1answer
340 views

How can I test Post Callout with web token's access? HttpCalloutMock

My POST Method (data for web token - is my custom object's fields): public class Token{ public String accessToken{get;set;} } public static String accessTokenBody(){ //our web token (data is in ...
0
votes
1answer
241 views

How to test access token for HTTP callouts?

I have an access token for my HTTP callouts. How can I test it if I wanna use Static Resource? But I can also use the HttpCalloutMock Interface. it doesn't matter My access token is in custom object. ...
1
vote
1answer
159 views

How can I test Callouts with HttpCalloutMock?

How can I test this method? I try the test code from trailhead but can't make any coverage. Callout: public class Token{ public String accessToken{get;set;} } public static HttpResponse ...
0
votes
1answer
67 views

Correct HttpPatch and correct test for it

I need to update a right record with ExternalID = Id of inserted record. And I try to check this field (ExternalID) in SOQL, but get an error System.QueryException: List has no rows for assignment to ...
1
vote
2answers
201 views

setting RecordType in Test Coverage

I am having trouble on a test that is setting a record type. I believe I am setting the record type the correct way, the test is passing, but my test coverage is telling me that no record type was set....
0
votes
1answer
215 views

Social Sign On for Salesforce Reg Handler Class and Test Class-System.NullPointerException: Attempt to de-reference a null object

My org is setting up social sign on with Google and I am running into an error I have never seen before: System.NullPointerException: Attempt to de-reference a null object Does anyone know a ...
1
vote
1answer
34 views

What kind of test can I write to check the file?

I have a controller for VF Page. This code upload a profile's image (we can see it after that) and delete it. What kind of test can help me to check this file? I need to know, is it uploaded or not. ...
0
votes
1answer
249 views

Static method cannot be referenced from a non static context (PageReference)

What is wrong here? Candidate__c cand = new Candidate__c(); insert cand; PageReference pageRef = Page.UploadCandidatePhotoVF; Test.startTest(); Test.setCurrentPage(pageRef); ...
0
votes
2answers
153 views

Make the test work: File insert, check this File

This code is a controller for my VF Page. It inserts ContentVersion and ContentDocumentLink. After that a candidate field Photo__c take a ContentVersion.Id value. How to check it correctly? Now ...
0
votes
1answer
42 views

Trigger Test fails because check for roll-up field value in Trigger finds old value

I have a trigger on a custom object, Subscription__c, (child of Account) which is supposed to give the Account TelemarketingPrioritizedFor__c = 'Winback' if, and only if, the field ...
1
vote
0answers
32 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
111 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
486 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
39 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
480 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
1k 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
72 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
97 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
81 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
54 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
114 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
320 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
773 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
1k 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
1k 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
101 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
72 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
280 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
125 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
65 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
94 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
196 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
111 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
710 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
417 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
344 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 ...