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)

1
vote
1answer
11 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
3answers
29 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
30 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
123 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
24 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
20 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
42 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
30 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
28 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
34 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
39 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
26 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
26 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
19 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
27 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 ...
0
votes
0answers
21 views

Test class of below class [closed]

How to write test class for this class? public pagereference prepareSFDocuments(){ attNames = attNames.removeEnd(';'); List<string> atts = attNames.split(';'); ...
-3
votes
0answers
22 views

Test class of following

global with sharing class FileUploadController { public PageReference cancel() { return new PageReference(ApexPages.currentPage().getParameters().get('retURL')); } }
2
votes
1answer
31 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
103 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
20 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
24 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
42 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
34 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
45 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
34 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 ...
-3
votes
1answer
26 views

Trigger Test Class code coverage not increase over 29

I have written the trigger below trigger CreditrequestTrigger on Credit_Request__c (after update) { String body = ''; String subject = ''; List<User> Userlist = new List<User>([SELECT ...
2
votes
1answer
45 views

test class of wrapper class

I have written a controller class which for a VF Page which is supposed to display all the alarms for the parent account.Now the problem is that when I'm writing test class for this controller a ...
-4
votes
2answers
44 views

How to write test class for this custom controller?

<apex:page controller="myController" tabStyle="Account"> <apex:form> <apex:pageBlock title="Congratulations {!$User.FirstName}"> You belong to Account Name: <apex:inputField ...
2
votes
2answers
63 views

Test Method That Accepts Date Parameter Doesn't work

I'm posting the challenge question to the Trailhead Beginner 'Apex Unit Tests' module. Install a simple Apex class, write unit tests that achieve 100% code coverage for the class, and run your Apex ...
4
votes
1answer
25 views

System.Assert Failing in VF Controller Test Class

I'm attempting to run a test class for a custom Visualforce controller but am having an issue with my System.AssertEquals method. Controller: public without sharing class CC_LegalController { ...