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

System.AssertException: Assertion Failed: Expected: SQL, Actual: null [closed]

I have the following test class LeadTriggerTest which fails with the following error: System.AssertException: Assertion Failed: Expected: SQL, Actual: null Class.LeadTriggerTest....
3
votes
0answers
664 views

Reference field returning NULL in Test class only

We are facing a very strange issue when writing proper unit test using asserts. We have two objects which have logical link with a field. So, we wrote a batch class to relate those two objects using ...
4
votes
1answer
3k 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 ...
1
vote
0answers
49 views

Test method failure - expecting a DML error but not getting one

I have a test method that is failing because it is expecting an error, but isn't getting one. Here's the test method: static testMethod void assignToSelf_DmlError() { setup(); Test.startTest(...
3
votes
1answer
154 views

Test class completes successfully in production AND newly refreshed sandbox, but fails on deployment

We have some custom code from before I joined the company that is showing some unusual behavior. Code was somehow successfully deployed to production (before my time), and the test code passes within ...
0
votes
1answer
38 views

My method is failing in test

List<Contract> contracts = new List<Contract> { new Contract( AccountId = DB.getAccountByNUID('800000004').Id, Academic_Year__c = '2020-2022', ...
3
votes
1answer
1k views

Hierarchy Custom Setting Test Class Issue

I'm using a Hierarchy Custom Setting field in a validation rule but want my trigger to be able to override the validation rule whenever it runs. I have modified my trigger/helper class to set my ...
0
votes
1answer
551 views

Unable to cover to test class for below trigger

I have written trigger and a test class for my content version Handler public class handlerClassContentVersion{ public set<string>prodNames = new set<string>(); public set<...
1
vote
1answer
271 views

Need Help Optimizing SOQL Query For 100,000+-Record Table (old query, suddenly failing)

Although my org seems to have had over 100,000 Task records for quite some time (as of this morning, we're at 119,479), between a week ago and yesterday two of the test methods that come with an ...
1
vote
1answer
107 views

How to achieve 75% code coverage

When I checked below code in my dev. org. It was almost cover 97% code coverage but when I applied same code in my sandbox it was showing only 10% of code coverage. Strange! Please find below batch ...
-5
votes
1answer
799 views

Compile Error: Arithmetic expressions are not allowed on void types. at line 36 column 26 [closed]

@isTest private class Testcontactcloud{ static testMethod void unitTest(){ Test.StartTest(); contactcloudcontroller objccc=new contactcloudcontroller(); ...
0
votes
1answer
43 views

Company names list configuration test method

I have the following method public static String splitCompanyName(String company) { String companyNameLowerCase = company.toLowerCase(); // get all extensions from the salesforce list and are ...
0
votes
1answer
3k views

How to cover pagereference method in test class

I have a method like page reference method in my class. How to cover the pagereference method in test class??? all the other methods were covered except the pagereference method. I tried like: ...
0
votes
0answers
169 views

System.Null pointer exception error on an empty line of code?

I am getting below error in a test class when I want to save another class. System.NullPointerException: Attempt to de-reference a null object at line 32 The problem is that I commented line 32, but ...
3
votes
1answer
1k views

Query works in Anonymous Window but fails in Test Class

I am new to APEX and ask forgiveness if the answer to my question is obvious, but I can't find a reason for the action that occurs in the Test class versus production and the Developer Console ...
1
vote
2answers
52 views

Apex Test issues creating a quote - page error missing or inactive pricing type/pricebook

I am trying to update some older test code to remove seeallData=true. I am getting a page error testing a quote controller extension that creates a new quote. System.AssertException: Assertion ...
0
votes
1answer
53 views

How to properly create and use test data for test classes?

So I've had gained a lot of experience coding apex classes and Visualforce pages but there is still one concept that is really causing frustration for me and that is how to write proper test classes. ...
0
votes
1answer
46 views

Need help in test class for code coverage

I have a requirement, where i need to populate all the related contacts in Account Object Detail Page with comma seperated. For Example : If I have Account1 and Contact1 and Contact2 are related to ...
2
votes
1answer
80 views

Trying to Bulkify Code now running into test failure

I have a trigger that when a campaign member record is created or updated it will write the campaign ID to a field either on the Lead or Contact. I started with this code but it was not Bulkifed as ...
1
vote
1answer
143 views

Apex trigger: Test class Assertion failed

I am new to Apex triggers. Could you please help me with an issue I have with my test class? I have a Master-Child relationship between Person account and a custom object called ...
0
votes
1answer
2k views

How to assign an Account Name on an Opportunity Test Class

I am creating a @testClass for an Apex Trigger I wrote with the intent to automatically set an Opportunity Checkbox field to False, if the Opportunity was cloned. (The Else statement also defaults the ...
7
votes
1answer
551 views

Test class passes in MavensMate, but fails in Apex Test Execution

Basically subj: Some of my test classes pass when I run them in MavensMate, but fail when I run them in Apex Test Execution in the org itself. MavensMate: Apex Test Execution: And just because I ...
0
votes
1answer
255 views

Subquery on Account for NotesAndAttachments not returning any records

I have written a Batch class that will check for Account records with no child records and delete them. Among the sObjects I need to check are Notes and Attachments. Because I have more than 20 child ...
0
votes
3answers
981 views

Test Class Coverage Issue with Trigger.newMap != Trigger.oldMap

I'm hoping I am missing something obvious. I have a Lead Trigger & Handler class. The Handler forces Assignment Rules to fire if a Lead Checkbox field IS CHANGED to True. After Update. It is ...
0
votes
1answer
33 views

Test Class only creating 1 case and email object

I attempted to break up the class based on the different scenarios that might come up, but now I'm only getting 1 case and 1 email message as it's not taking the queried user Id's. @isTest public ...
0
votes
1answer
113 views

Unit test for page reference

I had this pagereference method, My testmethod is static testMethod void testvalidate() { String userid = UserInfo.getUserId(); Map<String, String> QR = new Map<String, ...
2
votes
1answer
4k views

test fails because of TestMethod do not support getContent call

My below test fails because of Run Failures: TestRangehoodObjectionSheet.RangehoodObjectionSheetTest Methods defined as TestMethod do not support getContent call. I added the Blob thinking it might ...
1
vote
3answers
74 views

0% code coverage on apex manager class

I despair at the moment getting the code coverage on a newly created apex class. It's a manager class without without any sObject references which I plan to use for triggers and other manager classes....
0
votes
2answers
112 views

Why is my test class not covering the methods?

Code for the controller public class AccountSearchControllerNew { public String varPhone{get;set;} public String varEmail{get;set;} public String varStore{get;set;} public Boolean ...
7
votes
3answers
1k views

After winter 16 upgrade, started receiving error for test failures while deployment:Methods defined as TestMethod do not support Web service callouts

Our org got upgraded to winter 16 last Friday October 16. When I used to run all test few tests were failing with error: Methods defined as TestMethod do not support Web service callouts however, now ...
0
votes
2answers
548 views

System.QueryException: List has more than 1 row for assignment to SObject3

In the test class I am getting the error as above one? Class.TW_RestAPI.getTwiML: Class.TW_RestAPITest.testPostRestService @istest public class TW_RestAPITest { static testMethod void ...
0
votes
1answer
42 views

Test classes - unable to store variables for later assertions

I am somewhat of an Apex newbie and I am running into issues with the following steps. My test class was passing correctly but after some feedback I was instructed to place all my assertions after the ...
0
votes
0answers
194 views

One or more Apex triggers lack test coverage. Add test coverage for the following

Upload Failed One or more Apex triggers lack test coverage. Add test coverage for the following triggers and upload again: EmployeeScheduleTrigger I have covered pretty much more than 75% of the ...
0
votes
0answers
337 views

Trigger to Populate a Lookup field on Opportunity

I have created a Trigger to auto populate a lookup field on Opportunity as that was not possible with a workflow and had to reference that field in Exact target as in Exact Target we can only refer ...
0
votes
0answers
256 views

System.NullPointerException: Attempt to de-reference a null object when creating Lead Object in Test Class

Getting this error when trying to run this test class: @isTest (SeeAllData=false) private class RL_Test_UpdateLeadType { @isTest static void test_method_one() { // Implement test code ...
1
vote
1answer
583 views

System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Lead.ConvertedContactId [closed]

I'm writing a test class, but line 14, constantly throws an error when I'm trying to create test Lead objects. Here's my code and the error is the subject line of this post. @isTest (SeeAllData=...
1
vote
2answers
78 views

Assert Failing - cant update apexclass

We have a class that was previously deployed into production. I have made a small change to the class, simply modifying a string that contains the campaign name so we can use the class on a new ...
1
vote
2answers
77 views

Unit test deadlock

background story: We slipped under the 75% test coverage. In addition to writing new tests I deleted some old classes (no longer needed ones). Problem: Deleting classes which are still referenced in ...
1
vote
1answer
86 views

Test Class on @future method won't pass

I'm trying to finish my test class for a @future method, but I just can't seem to figure out my syntax. We have an automated system that creates User records. We've added a trigger than uses the ...
-1
votes
2answers
59 views

does a test class need to pass?

I have written a test class for my apex class The test class covers 98%. but the test class fails. will the coverage be considered.?
0
votes
2answers
45 views

Need help with the error writing test class

I am writing for the simple triger created. I don't understand why i am getting this error while all I am trying to do is create account record with one field name? System.DmlException: Insert ...
2
votes
0answers
247 views

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY on Communities Change Username Page Test

I created a visualforce page for Communities users to update their username and email. In real life the page works fine, logging in as a Community user I can update my username and email. However, I ...
1
vote
1answer
44 views

Unable to make coverage for the below class

I have written a test class for the apex class.I am not able to cover the following portion .can you help me out. thanks in advance Apex Class: //Generated by wsdl2apex public class ...
0
votes
2answers
610 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 ...
0
votes
1answer
129 views

My test class won't pass

Requirement: When an email is synced to Salesforce from Outlook, whatever Lead or Contact is associated with it needs to have the custom field Email_Opt_In__c checked. That part is working just fine. ...
1
vote
1answer
262 views

failed test classes wont be included in code coverage

I want to know if some of the test classes fails in production then they will included in code coverage or not?. in production org i m getting 74% code coverage. I am unable to deloy a class. can ...
0
votes
1answer
418 views

Execute Anonymous works with trigger, Test Class Doesn't

I have written a trigger that will aggregate into a list all instances of an opportunity picklist on any contact with a (opportunity) contact role relating it to an opportunity. I.E. Contacts A and B ...
2
votes
1answer
575 views

Test-failure: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

I have a APEX Test Method that has started to throw exceptions (don't know if this is related to a new release) but I'm not sure what to do to avoid these exceptions // Using this 'user' to avoid ...
4
votes
2answers
71 views

Failing test is showing as passed

In Debug Logs I can see a System.NullPointerException for the unit test that was just run, but on the Apex Test Execution page I see the test as passing. The error is not buried within the log details;...
3
votes
1answer
309 views

Describe call inconsistent in test class

In the Apex class below (executed in a client org), testA() passes while testB() fails. The failure is an assertion error from the ServiceLayer constructor. /* SF API 33 */ /* PKG version 1.55 */ ...