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
22 views

In a test class example of a Post Install script, sending an email and scheduling a class that performs an API callout

Scenario: In my example, as a part of the PostInstall (class implements InstallHandler) script I will be performing two actions; - sending an email to the installing User for the express purpose of ...
0
votes
1answer
25 views

how to make a test so that the lead owner is the same as the contact owner

I'm starting to learn apex and I need to write a test for a simple trigger so I can have 100% code coverage. Here's my trigger: trigger UpdatePropietario on Lead (after update) { Id pId; for(...
0
votes
2answers
19 views

SOSL not returning record in test

I have EditorModalController.searchDoctors that returns a list of contacts. public class EditorModalController { @AuraEnabled public static List<Contact> searchDoctors(String ...
0
votes
1answer
40 views

Why are field updates inside an Apex trigger not showing up in an Apex test?

I have a very strange issue with some Apex tests for a trigger. The tests each check a different type of field update; when one field is changed, the trigger is supposed to change another field. On a ...
3
votes
1answer
536 views

Testing @future method Failed Assertion

I have some code that after inserting a task, calls an @future method to update some fields on the contact linked to that task (WhoId). This seems to work fine in sandbox, but I can't seem to get it ...
-1
votes
1answer
28 views

How to cover the SETENDPOINT kind of lines in test class [duplicate]

**APEX-CLASS** public class TriggerFlodataWorkflowController { public string inputIds{get;set;} public List<String> selectedNames{get;set;} public List<String> selectedIds{get;set;} ...
0
votes
1answer
43 views

Code Coverage 83% in production 75% in sandbox - can't deploy

In production, code coverage is showing 83%. In sandbox, it is showing 75%. I have just 1 apex class and associated test class I am trying to deploy to production, but it fails saying only 30% ...
0
votes
2answers
23 views

How to cater opportunity insertion in my TEST class

I have a method in APEX class that does variety of checks via If else conditions with some SOQL statements. I created test data(Accounts, custom object records) to test the SOQL statements and it ...
0
votes
1answer
26 views

Get test failures dynamically (as it goes) when uploading package, but not all at once in the end of upload process

When we are uploading our huge managed package, it takes up to 3 hours for process to finish and the major part of it are taken by tests execution. The inconvenience here is that tests failures are ...
1
vote
2answers
63 views

How can I create 1500 contacts for my units tests without hitting CPU limit?

I am creating a script that gets run every quarter that checks for any paid status in campaignMember objects that has contactId attached, and update the status to unpaid and create a campaignMember ...
0
votes
0answers
40 views

APEX Test Class: Round Robin Lead Distribution Model

The original question can be found here. However, as an overview, the code is responsible for assigning Leads to sales representatives with round-robin distribution based on the Queue that is assigned ...
1
vote
2answers
98 views

Process Builder causing Apex Test class failures - How to handle?

Hoping someone can help with the following issue I am currently experiencing. I have created a new process via the process builder that sets the Contact owner to be the same as the Account Owner on ...
2
votes
2answers
53 views

FIELD_INTEGRITY_EXCEPTION, High Volume Portal Users cannot have a user role - Test class

The user role created below is not 'High volume Portal User' but, still production deployment validation fails with error "FIELD_INTEGRITY_EXCEPTION, High Volume Portal Users cannot have a user role". ...
0
votes
1answer
27 views

Task execution of AfterInsert Error for Task Trigger CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

So I have a trigger and a class that works perfectly when I manually test in sandbox but when I run a test class, I get the below error: 13:50:50:330 EXCEPTION_THROWN [49]|System.DmlException: Insert ...
2
votes
1answer
136 views

sfdx force:apex:test:run all local tests failing

I have a sandbox org (not scratch org). I authenticated it with alias e-devint When run RunLocalTests (hundreds apex test files), it fails quickly with the error below. The error doesn't tell much. ...
0
votes
0answers
64 views

How to create a correct test for knowledge articles?

I'm creating a package with a simple Apex class that retrieves info about knowledge article (Lighting Knowledge). However, I'm having an issue with a test. When installing the package via installation ...
4
votes
1answer
2k views

Process Builder - Failing test classes

I've written a flow in process builder which references an Apex class with @invocable method. I've written a test class for the same and it's passing as well. Now the problem is all the other test ...
0
votes
0answers
53 views

Unable to write BestCommentId on FeedItem in test class

I am trying to write a test class to test an Apex class that uses FeedItem object. The Apex class checks if the FeedItem record has a BestCommentId and does some actions. A snippet of the test data ...
8
votes
1answer
119 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
0answers
42 views

System.ListException: List index out of bounds: 0 in test class when we try to query ProcessInstanceWorkitem [duplicate]

I am getting List index out of bounds exception when I try to query ProcessInstanceWorkitem in test class. Below is the code snippet in the main class: ProcessInstanceWorkitem[] piw = [SELECT Id ...
2
votes
2answers
34 views

Apex Test Class Failure: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

I am at a loss for this one and could really use some help on this. I have a vf page and apex extension that is used with a site. Everything works when I test this via the UI but for some reason I am ...
0
votes
2answers
510 views

Validation rule and Managed Package

I have a Validation rule in ShippingPostalCode in Account Object. Validation rule check for US Standard format and field should be required. When I run runAllTest from Developer Console. Managed ...
5
votes
0answers
2k views

error from test method - “apex job is already scheduled for execution”

I have a batch apex which starts itself after x mins. this is done in finish() method using , system.scheduleBatch() method. below is how the batch looks like, global class my_ProcessPurge_Batch ...
0
votes
1answer
150 views

How to solve this deployment errors (Variable does not exist: isReadOnly)?

Trying to deploy package (big one) to a new org but all the tests failed with very weird errors: 1)line -1, column -1: Dependent class is invalid and needs recompilation: Class ClassName : Variable ...
4
votes
2answers
956 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
2answers
142 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: ...
0
votes
2answers
27 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
36 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
40 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){ ...
1
vote
1answer
412 views

Unable to insert group during tests - “Group Already Exists” with SeeAllData=False

Create a class to automatically add user to chatter groups. I wrote a test class to cover the code. The class is working fine and covering code if I add SeeAllData=true. Issue: If I remove seeAllData=...
0
votes
2answers
115 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
77 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
38 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
37 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
397 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
36 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
29 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
91 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
43 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
172 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
153 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
46 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
23 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
30 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
384 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
154 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
157 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
84 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
46 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
144 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....