A unit test is code that is written and executed to test a specific portion/unit of source code. Unit tests are class methods with the testMethod modifier or @isTest annotation and are usually placed in separate test classes annotated with the @isTest annotation. Code that is executed by unit ...

learn more… | top users | synonyms (3)

0
votes
1answer
18 views

How to write testmethod for geopointe.actionHandler

I have a few classes written that implements Geopointe's action handler, but I don't know how to go about writing a test class for them. All I can find are test classes written for the schedulable ...
2
votes
0answers
27 views

Test Queueable Apex: Methods defined as TestMethod do not support Web service callouts, test skipped [duplicate]

Hi I'm testing a queueable apex class with callouts in it. But I got error and have no idea how to fix it. Callout Class: global class CE_GetSessions implements Queueable,Database.AllowsCallouts{ ...
0
votes
2answers
19 views

System.QueryException: List has no rows for assignment [duplicate]

I've read a lot of answered questions about this error but I can't seem to resolve it. I would very much appriciate any help. I am trying to test my Extension Controller from a SF Page but I keep ...
-1
votes
2answers
37 views

Apex Class Fail: Trig_Contact: execution of AfterInsert caused by: System.ListException: List index out of bounds: 0 [on hold]

I have an old Test that is causing some of my new Triggers to fail on deployment and would love any help I can get! It's worth nothing that the fundraiser object is now a child of campaigns, so the ...
0
votes
1answer
52 views

Help Writing a Test Class [on hold]

I've created a Visualforce page and a custom controller to use with it. Not being a developer, this was a heck of an exercise for me! Anyway, as you may have guessed, my class failed the validation ...
0
votes
0answers
21 views

Test class coverage and failed assertions

I have written a VF page where knowledge articles are displayed as a PDF. Now for constructing URL i took help of custom controller and hence i had to write a class for it as well. The problem i'm ...
1
vote
1answer
12 views

Does runalltests run test cases for managed packages?

Does this parameter run all the test classes for the managed packages Or does it run only for the unmanaged packages ?
1
vote
2answers
30 views

Please help me in writing test class for my triggerclass

I have written a trigger to send email to particular email groups whenever a "Idea" record is created. I have to send emails to groups on the basis of combination of two multi-select picklist fields ...
1
vote
1answer
32 views

How to write a test class for an apex class with do post method

I have tried to write a test class for the below class with post method. But i am not able to bring the coverage.How can I approach this. Thanks in advance. /* code starts here*/ ...
4
votes
2answers
136 views

Test coverage for a wrapper class

I've got the following wrapper class that has no constructor, methods, getters or setters: public class Vehicle { public class RegistrationInfo { public String registrationId; ...
0
votes
1answer
25 views

Constructor error message on test class for pagination

I have a visual force page to display a list of locations. I used pagination and wrote class for it and working finely. but the test class is giving me an error : Constructor not defined: ...
0
votes
0answers
21 views

New XML parsing trigger rejects any code coverage from its test class!

I just wrote this simple XML parser trigger to temporarily help me update a diagnostic object with additional integration data, without having to request the integration to run for all records. I ...
0
votes
0answers
14 views

Help: Visualforce Form Entry Test Class

Please help on this visualforce form entry test class. Below is what I have soon far. Test Class: @isTest public static testMethod void NetworkSitesCtrlTest() { PageReference pageRef = ...
4
votes
1answer
46 views

URLFOR/Component.Apex.OutputText in Unit Test causing Internal Server Error?

Background I'm trying to build the usual "URL hack" to default some field values when a new record is created. This is a simple override that basically has a page like: <apex:page ...
0
votes
1answer
18 views

Test Class with Account Transfer

When the account records transferred to another user, the associated open opportunities automatically transferred to the new account owner without firing the opportunity trigger. See my post (Account ...
0
votes
2answers
33 views

Need test class for this method

I need test class for the method below: This class is written for overriding the view.. public PageReference redirectGroup() { if(Url.getSalesforceBaseUrl().toExternalForm() == ...
1
vote
2answers
37 views

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER on a test class [duplicate]

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed ...
0
votes
1answer
30 views

Test Class for Controller with many if conditions:

How to write test class for following controller. I am able to write it for only one if conditions. public with sharing class ControllerExtension { Id Param1= ...
0
votes
2answers
36 views

How do I test for an exception('addError')?

Wrote a test class for a class which code coverage is 86%. How do I test for an exception('addError')? Have a look for (Account_Affiliation__c a: c.R00N300000014qT8EAI__r) { if (a.recordtypeid ...
0
votes
1answer
29 views

Test Class - Getting values of new record

I've got a class that generates a new opportunity record. I want to verify that the opportunity was generated in some instances but not in others. I'm new to apex, how would I go about getting that? ...
0
votes
2answers
40 views

How to increase test coverage when Ids are hard coded in the trigger?

I have a trigger on Opportunity which runs when the Opportunity is closed as Won. The trigger checks if the Opportunity line item has a specific product(Id is hard coded in the code) and then does ...
2
votes
2answers
28 views

How to disable the debug log for other classes except for my class?

I am trying to increase the test coverage and it keeps failing and few of the useful debug log statements from my test class are not showing up and below are the ways I tried: 1): ...
0
votes
2answers
52 views

Code Coverage not reaching 100%

I created a trigger and 2 test classes. They only cover 73% and I can't figure out why. The trigger updates the field "Email_Opt_In__c" on the Lead/Contact that is a campaignMember with a "Registered" ...
1
vote
1answer
19 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
33 views

How i will write test case for this class ?plz help me

public with sharing class CRM_AddProducts { public String message { get; set; } public String SelectedProduct { get; set; } public list < pProduct > lstproduct { ...
1
vote
2answers
27 views

How to write a test class for a custom controller [closed]

i'm a newbie in terms of apex programming. Where i not very sure how write a test class, with 75% coverage.
0
votes
0answers
22 views

Salesforce Controller Test: getAccounts method not filtering by profile

I have a custom controller that is intended to return a results set to a visualforce page for customized viewing. It works fine in production. When building my unit test for this controller, ...
0
votes
1answer
23 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 ...
1
vote
1answer
29 views

DuplicateRecordSet and Item objects in unittests

Does anybody know how to write testmethods for Duplication Rules? I have created the Account Duplicate Rule with init conditions: Current User: Profile not equal to System Administrator with ...
4
votes
2answers
29 views

Manager is Required when inserting user through test class

I have to insert (User) through test class for that I have inserted (Profile) first , then after inserted (User) and passes that profile to profileId. It is Getting Saved but when i run the test class ...
0
votes
1answer
21 views

I have written test class for email sending functionality class trying to cover code up to 100% but covered 80% only?

public class CheckboxEmail { public boolean cbox{set;get;} public String emailTo {get; set;} public String emailBody {get; set;} public String response {get; set;} public PageReference ...
1
vote
1answer
18 views

Bypass Lookup Filters in Test Class

I'm creating some setup data for a test class. I'm wondering if there is annotation to turn off the Lookup filters during the test? I have removed the filters currently, but will need them after the ...
-3
votes
0answers
23 views

Test class of following [on hold]

global with sharing class FileUploadController { public PageReference cancel() { return new PageReference(ApexPages.currentPage().getParameters().get('retURL')); } }
2
votes
1answer
32 views

Mock child events in test class

I need to create a child event isChild=true with apex. I need it in my test class. any suggestion. Event ev1=new Event (OwnerId=u.Id, Subject= 'Appel', WhoId = whoCon.Id, ...
0
votes
0answers
15 views

How to write a test class for the following

public with sharing class CreateNewDealController { public Opportunity deal {get;set;} public CreateNewDealController(Apexpages.standardController sc){ deal = (Opportunity)sc.getRecord(); } ...
-1
votes
0answers
20 views

How to write test class for this class

global with sharing class FileUploadController { public PageReference cancel() { return new PageReference(ApexPages.currentPage().getParameters().get('retURL')); } public string ...
-1
votes
1answer
21 views

Apex Test Class for Chatter Auto-Follow

I had some great help with getting my Class to work properly (Apex Auto-Follow in Chatter). Now I'm writing my first Test Method, and running into an error I can't seem to work around. Apex Class: ...
1
vote
1answer
38 views

Help with Test Class

When you have a trigger or a class to write unit test for, one would setup the data structure and then execute your code against the data by insert or calling the class between Test.start() and ...
1
vote
2answers
105 views

RestResponse does not return expected statuc code in Apex Rest unit test

Apex Rest returns 200 OK status code when directly access its Rest endpoint. However, in Apex Rest test class. RestResponse hooked in RestContext does not contains the status code (see below debug ...
3
votes
0answers
21 views

Developer Console Test Logs: Unable to Access Page

As I'm running the debugger I am attempting to review the execution logs from past test-executions that have completed, however, when I click the class in the Test tab of the Developer Console I get a ...
2
votes
1answer
17 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 ...
0
votes
1answer
27 views

Pass inner class object as an argument to apex class

I have following apex class as an example. I am writing unit test case for apex class and passing inner class object ref as an argument. When I try to save my test class it is giving me compilation ...
1
vote
1answer
43 views

Unit Test for Simple Before Delete Trigger

I am receiving 0% coverage on the below trigger which seems simple enough. Can anyone please advise here? My unit test is below. trigger CannotDeleteAccount on Account (before delete){ for ...
0
votes
0answers
39 views

Test class for http callout on documents

I have a class that makes a HTTP callout and gets the csv response and save it to the content in salesforce. Apex class: public class MYSQLCSV{ public Static void MySQLCSVContent(){ Http ...
1
vote
2answers
18 views

How to write assert for a method in test class

I need to write system.assert for the following method in my test class: public PageReference back() { return new PageReference('/apex/Rforce_VehicleFinderForCase_Page?Id='+accountId); ...
1
vote
2answers
41 views

Test class not running for a different user

My test class is supposed to check functionality of a controller for a VF Page which displays alarms for the parent account.Now according to the functionality I'm inserting alarms as admin ...
2
votes
1answer
46 views

Code Coverage 71% (5/7)

Not sure where am I missing but not able to get over 75%. Below is the Class and a test class: Apex Class: SetCustomOwnershipOnOpportunity public class SetCustomOwnershipOnOpportunity { public ...
0
votes
1answer
23 views

test class for a non admin profile

I'm writing test class for an extension controller supposed to display alarms for a particular account.Now in the test class the condition is that I have to insert alarms using one profile and then ...
-1
votes
2answers
39 views

Error: Compile Error: unexpected token: ')' at line 12 column 10

I am getting error on line 12 : Error: Compile Error: unexpected token: ')' at line 12 column 10 and i am not getting what system of my code is wrong ? here is my code : String RTid = ...
-1
votes
2answers
25 views

Issue with Test Method, covering 70% instead of 100% [closed]

Apex Class: public class Nanostuffs_clsConvertLead { public PageReference convert() { try { String id = ApexPages.currentpage().getParameters().get('id'); Database.LeadConvert lc = new ...