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
104 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
700 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
145 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
79 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
131 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
1k 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
546 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
229 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
914 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
105 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
70 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
106 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
535 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
190 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
324 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
538 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
76 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
77 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
234 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
43 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
532 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
125 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
249 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
370 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
558 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
290 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 */ ...
0
votes
1answer
2k views

“Required fields are missing: [ProfileId]: [ProfileId]” when running Apex Class Test for ChatterAnswersAuthProviderRegTest

I am conducting an Apex test for ChatterAnswersAuthProviderRegTest, as I run this test, I encounter the following error message. System.DmlException: Insert failed. First exception on row 0; first ...
0
votes
2answers
68 views

Need help raising Code Coverage

I've been working on a trigger to auto-populate some information that goes into our company's Tasks. I have come up with the following trigger/test class but can only seem to get Coverage around 45%. ...
1
vote
2answers
273 views

Cleared Code Coverage cache

How can I clear the code coverage and I'm stuck to 60% and regardless its not what test I write its not increasing but my question is: is there a way to flush the cache?
2
votes
1answer
69 views

Trigger isTest coverage stuck on 61%

I have already spent few hours trying to figure out why I'm stuck on 61% and try to add or remove the test methods but no avail. I have the following test class that is only getting 61% coverage on ...
0
votes
1answer
276 views

Same test class works in one sandbox but not another

I have one test class which is working fine in one sandbox but same test class is getting failed in other sandbox. Below method is not working in Sandbox which may be cause of error. Error: ...
1
vote
2answers
66 views

I need 1:1 help with some Apex code coverage issues, how to ask? [closed]

I want to respect the community here so I'd love your feedback on the best way to go about this: I inherited an org with some code coverage issues. I'm a beginner developer at best and trying to work ...
0
votes
0answers
37 views

Test class assumption failing after 2 years

I have a test class that has been in production for nearly 2 years. It is mostly self contained including an XML string that is interpreted and then broken into the component parts and stored. Then we ...
2
votes
2answers
53 views

What else besides an Apex Trigger could affect third party Tests Cases?

I have a customer who installed our package in their sandbox and their tests are failing in our namespace (That's just the information that the stacktrace shows). The weird thing is that their tests ...
1
vote
2answers
266 views

get error while updating object in trigger test class

I have a trigger on custom object object called File_Uploaded__c which has an attribute : IsMain__c of type checkbox, and the trigger maintains only one file as main : trigger setIsMain on ...