Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

3
votes
2answers
96 views

How is it possible for @TestSetup to effect test result?

While refactoring a test to make it more consistent with the style of our other tests, a colleague came upon something really weird. The original test created the test account in @TestSetup, like so: ...
-2
votes
1answer
43 views

how to cover code coverage of class for get records from REST API [closed]

getHousingList() have if() condition which is not covered by my test class @HttpPost global static List<HHSurvey> getHHSurveyList() { RestRequest req = RestContext.request; ...
8
votes
1answer
89 views

Set.retainAll () on API 45 dies with UnexpectedException

I have a weird issue, can somebody help? On API 45, the following test crashes with FATAL_ERROR System.UnexpectedException: java.lang.String cannot be cast to apex.bytecodeinterpreter....
0
votes
2answers
20 views

TestMethod do not support Web service callouts

I want to invoke a Process from the record base Process using invocable apex which invokes Process by making an HTTP request to the Rest API. But when I try that it's causing many of our existing ...
0
votes
0answers
26 views

Test Classes: MIXED_DML_OPERATION

Via Process Builder, Is there anything I can do in my process that could stop this from occurring? Error Message: System.EmailException: SendEmail failed. First exception on row 0; first error: ...
-1
votes
1answer
36 views

Test CLass code coverage problem

trigger Updaterelatedoppty on Account ( after update,after insert , before insert,before update ) { //before trigger if(Trigger.isbefore ) { for(Account acct :Trigger.new){ ...
0
votes
2answers
28 views

Inner Class Cover in Test Class

Please help me why my code coverage is showing 0% . See my class code and test class code where I have written wrong? Class public class InnerClass { public class Wrap { public string ...
0
votes
2answers
56 views

Test Class - Error - Constructor not defined

Error - Constructor not defined: [PrepareSandboxPostCopy_Batch].() Test Class @isTest private class SandboxPostRefreshTestCase { static Testmethod void testSandboxPostCopyScript() { ...
1
vote
2answers
30 views

Insertion Failed

I was writing the test class and found the below error and i am unable to figure it out .. System.DmlException: Insert failed. First exception on row 0 with id a0D1h0000003rUREAY; first error: ...
0
votes
1answer
29 views

Malformed JSON: Expected '[': wrong test, callout or mock?

I have System.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set and I don't know how to fix it. Callout: public class Callout { public List<Tool__c> toolsList; public ...
1
vote
1answer
122 views

Test Class for Trigger before insert before update

I am very new to APEX and I have written the following trigger that updates the due date on a case based upon an SLA value stored in another object once the user fills a value in a lookup field ...
-1
votes
1answer
24 views

Test Class failing due to Mixed DML Operation Error on User

Error :- System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (...
0
votes
1answer
26 views

How to fix wrong test controller's filter by status?

public void byStatus(){ //Temporary multipicklist, because my main picklist isn't multiselected: String temporary = jobAdvertisement.Temporary__c; List<String> temporaryList = new ...
1
vote
1answer
50 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
26 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
85 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
121 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
43 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
22 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
26 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
80 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
33 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
45 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
40 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
26 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
73 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
172 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
31 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
96 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
42 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
38 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
23 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
91 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
28 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
29 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
26 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
1k 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
97 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
19 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
152 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 ...
2
votes
1answer
476 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
43 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
74 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
31 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
35 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
67 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
155 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 ...
0
votes
0answers
216 views

System.XmlException: Failed to parse XML due to: only whitespace content allowed before start tag

handler class: public class IRIS_Contact_Campaign_Handler { public static boolean recursiveFlagCheck = false; // Defining the End Points of Marketing Cloud URL Static String ...
0
votes
1answer
779 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
328 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 ...