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

Problem with test class - Too many SOQL queries 101

I have a test class that is failing due to too many SOQL queries. I'm assuming the fix is quite easy, but am struggling with how to bulkify the query. Can someone please assist? Full test class is ...
0
votes
1answer
13 views

Test Class Problem

I am having a hard time to run my test class for my trigger WHERE my trigger updates the Contacts Mailing to Accounts Biliing Address whenever the Accounts Billing Address is updated. This is my ...
0
votes
3answers
33 views

test class for a trigger

I have 2 triggers into sandbox that work s perfectly and I want to transfer it into production. The only problem is that I need to write a test class for each one in order to cover 75% of the triggers ...
0
votes
1answer
20 views

Test Class - Code Coverage [on hold]

public with sharing class LeadSearchCon1 { Public List<Lead> getLeads() { return Leads; } Public void doSearch() { //I will build qryString step by step depending on values entered in ...
-2
votes
0answers
14 views

I had Written the Test Class it is Showing Any thing else could u help me?

public class Displayrecords { public list<Account> acclist{set;get;} public Displayrecords(){ acclist=[select name,Rating,AnnualRevenue from account limit 7]; } } @istest(SeeAllData=true) ...
0
votes
2answers
19 views

Unit Testing - Workflow Field Update

A SF newbie here. Is it possible to write a test class that can check WF field updates also ?. I have a WF update created on a Custom object CaseLog__c. Is it possible for me to write a Apex Test ...
3
votes
1answer
71 views

Best Practice - Lightning JS (Code reuse, testing frameworks and IDE support)

I asked about the difference between controller and helper and it prompted me to ask another, more specific set of questions: What is the best way to reuse JavaScript code across Lightning ...
-3
votes
1answer
21 views

Test class error [closed]

i have to pass the test class but the error is not resolving iam not bale to find the error can you please help what i have to do to pass this test class System.DmlException: Insert failed. First ...
2
votes
3answers
38 views

How to catch the field not in SOQL query error in a test class?

Is there any way to get this error: "Object row was retrieved via SOQL without querying the requested field: Any_Field_Name " in a test class so that if a new field has been added to the page, I can ...
0
votes
1answer
36 views

Spring '15 @TestSetup doesn't work

This test is supposed to succeed in a Spring'15 org, but doesn't. @isTest private class MyTest { static Integer value = null; @isTest static void testMethod() { ...
2
votes
1answer
38 views

Querying Time-based Workflow Queue

Is it possible to query the content of the Time-based Workflow Queue from an Apex unit test to assess that a specific Workflow Rule has been executed and added a new item to the queue? I didn't see ...
0
votes
0answers
20 views

Account and Contact test class [closed]

CLASS public with sharing class AccountUpdate { public static void doAfterUpdate(List<Account> newRecs){ Account_Source_Valuee__c.getInstance(); ...
0
votes
1answer
47 views

Need code coverage in if ,else blocks

Hi can anyone help me how to make code coverage for the following scenario? public PageReference doChanges() { selectedLineItems = getLineItemSelection(); if(selectedLineItems.size() > ...
0
votes
0answers
28 views

Test Class - How to create a Partner Account

My need would be to create a Partner Account (that is: an Account with field isPartner set to true!) in test class, having checkbox PartnerAccount set to true, but I'm not having success with this ...
-5
votes
0answers
29 views

Ho to write the test class for the below code [closed]

public with sharing class TfB_PB_RetrieveReachDetails { public String errorMessage = ''; public String accountId_15 = ''; public String accountObj = ''; public ...
0
votes
0answers
23 views

Test class for apex class containing external objects soql query

I wrote a test class for external objects. Since external objects are read only. I queried the external object record in test class. Created a new instance for controller in test class. When I ran ...
0
votes
1answer
27 views

About Apex Test classes

Few questions creating some confusion for me: Do we'v to write ALL SOQL and DMLS before test.start or after test.start method ? For e.g in case of DMLs, If I'm creating test Data for an object and ...
0
votes
2answers
32 views

test custom exception in catch block

I am trying to do a negative test and cover the catch block that uses a custom exception. Whatever I try it does not enter into my catch block? Here is my controller: public with sharing class ...
1
vote
0answers
20 views

How to TEST button initiated page redirect

I'm new to Salesforce and I'm trying to write some tests for our code. There is a button redirect initiated from the Visualforce page: <apex:page standardController="Happening__c" ...
0
votes
2answers
55 views

Test class not firing trigger update

I All, I am facing an issue with the test class. I have trigger on Insert and Update. I am using the test class given below which covers Insert trigger but do not cover the portion in Update. Need ...
0
votes
3answers
49 views

Apex CPU time limit exceeded (How to test trigger using large number of records?)

I wrote a trigger and need to use test the trigger by insert/update/delete large number I wrote one method to test the insert/update/delete trigger and I ran into Apex CPU Limit. My requirement is ...
0
votes
1answer
23 views

86% achieved in testclass how to achieve remaining 14% inside IF Statement code not working

Class public class Addcontrol { Public String msgbox {get;set;} Public String Name {get;set;} Public Integer expense_number {get;set;} public list<Expense__C> conlist ...
0
votes
2answers
32 views

95% covered how to cover remaining 5 % in test class in Wrapper Class

Wrapper Class public class Wrapper_class { public list<InnerWrapperclass> Wrapper_list{get;set;} Public class InnerWrapperclass{ public string Name{get;set;} public string ...
1
vote
0answers
17 views

How to insert Person Account record in testclass using Static Resource [closed]

I want to insert a person account record in testclass, how to achieve this? please help me on this task
0
votes
1answer
19 views

Test.loadData with sObject Throws Unknown field: Exception

Iam loading a CSV file via Static Resourced to test my APEX code. I am using the following code in my test: List<sObject> ls1 = Test.loadData(Account.sObjectType, 'TestAccount'); CSV file ...
0
votes
1answer
27 views

How to use Static Resource in testclass instead of Inserting a user [closed]

i would like to use Static Resource to insert a user in test class how could i achieve this.Pleas any one help on this.
1
vote
1answer
21 views

Issues trying to test Knowledge Base Articles

I have some code that queries KnowledgeArticleVersions and I'm trying to test it. In order to do so, I first need to add articles... @isTest public class ORC_TestUtils { public static void ...
6
votes
1answer
56 views

“Callout loop not allowed” in unit test for Queueable that implements HttpCalloutMock

I'm attempting to do a unit test for a Queueable that does an Http callout. When I run the test I get an exception: "System.CalloutException: Callout loop not allowed". Previously I was using ...
0
votes
2answers
35 views

List index out of bond 0

List<User> gmUser = [Select Id, Name, Email,GM__c,IsGM__c,Division,Mapped_UserID_Name__c from User where isActive=true and isGM__c = true and GM__c!=null]; ...
1
vote
2answers
22 views

Add test class in changeset?

Is it necessary to add the test class of an apex class in changeset during migration from QA to PROD? Suppose apex class is ABC_apexclass. Test class for the same is ABC_apexclass_TEST. Is it ...
3
votes
0answers
41 views

How to test controller extension for 'New' record use case?

I'm trying to create a test class for a null record. I have a vf page, and extension, that acts as a form for creating a new record. In my extension constructor I have the following code public ...
0
votes
1answer
21 views

Trying to make Apex Test Class for VF page extension class but keep getting errors

Trying to save this Apex Test Class keep getting error Error: Compile Error: Constructor not defined: [GoogleMap_Meeting_Controller].() at line 35 column 51 Here is the VF page extension: ...
0
votes
0answers
22 views

Need help with testing class for redirectling page

I'm unable to cover the last 3 lines of the apex class. Following is my Apex class.. public with sharing class redirect{ public String currentRecordId {get;set;} public List<orders__c> ...
0
votes
1answer
17 views

Test execution mode in spring 15 production

What is the default execution mode while deploying to production in current Salesforce release (Spring 15)? I'm trying to avoid the deadlock while running tests that use Custom settings. I could use ...
0
votes
1answer
24 views

Need help with Test Class for HTTP Callout

I have an extension to a vf page which makes an http call to a web service. I am tying to follow the salesforce guide for setting up the HttpCalloutMock Interface, though I don't quite get how to set ...
1
vote
3answers
30 views

Test Class Issue - My REST Method Isn't Getting Run

In my visualforce page I have a search field (inputText) with an id of 'query'. Query is passed into my controller and the runSearch() method starts a process which initiates a web service call. In my ...
0
votes
2answers
21 views

What's wrong with my email listener test class

I am trying to write a test class for my custom Email Listener class but receive an error message unexpected token: '=' at line 11. Can someone point out to be me what's wrong in my test class? ...
1
vote
3answers
44 views

Change Sets and too many SOQL statements

I'm at a point where I'm bumping up to a ceiling in the number of SOQL statements during deployment of inbound change sets - I have several VF pages, page controllers, triggers and test classes, and ...
2
votes
2answers
44 views

Invoking class for test question

The syntax of invoking the class in a test eludes me still (not so on triggers!). If my class is the simple: public class MyOppsApprovalExt { public ...
0
votes
1answer
37 views

Unable to cover few lines in Test class for pagereference

I am unable to cover the last 3 lines in the following class. Following is my APEX.. public with sharing class redirectOrderPartner{ public String currentRecordId {get;set;} public ...
1
vote
2answers
87 views

What is the execution context for unit tests?

If I'm building a unit test with a fair bit of overlap (for redundancy), and they all create leads for test purposes (without seealldata), at which point do those created objects get destroyed? Is it ...
1
vote
1answer
37 views

Apex trigger stuck on 0% test coverage; can't

I'm blanking on why my trigger is indicating 0% test coverage. I feel like I've treated it like my other triggers, but it is no different than it was when I didn't have a test class at all. Any ideas? ...
1
vote
1answer
36 views

Test class keeping the first constructor info as tmpvar1 but not using the new constructor variables

I am having problems with my test class. When I initialize the class and run my method qliUpdate1 scontroller1 = new qliUpdate1(new ApexPages.StandardSetController(qli1)); ...
0
votes
0answers
30 views

How to test the login method in the Site class

I'm getting the error: attempting to reference a null value when trying to test the login method of the Site class. I've tried to see if I can get any error messages. It might be that I'm not creating ...
5
votes
1answer
108 views

How Many Starttest() and StopTest() can I have in One Test Class?

The concept of testing org is still very new to me. I don't think I fully understand it. But can I've more than one StartTest() and StopTest() in my test class as my test requires many cases to ...
1
vote
1answer
18 views

Test Coverage of Class Variables

I have a utility class which is mostly instance variables. public with sharing class JSON2ApexLead { public cls_data[] data; public String account_id; //CL07e1BB74 public String client; ...
0
votes
1answer
31 views

Help getting test coverage for wrap class

I have been writing a test class from a wrap class but I am stuck in 77%, I don't know what else to try. I will appreciate any help. I added in the code the lines that are uncovered basically the ...
-2
votes
1answer
31 views

Help with unit testing of this class (apex noob)

I need help creating a test class for the following apex class in order to get code coverage. Any thoughts or examples that could help me figure this out would be greatly appreciated. A previous ...
0
votes
4answers
30 views

Help with test class create quote record

I have written a trigger ans test class. New to coding so could do with someone casting their eye over the test class as it doesn't seem to hit the 75% code coverage. APEX TRIGGER trigger ...
0
votes
2answers
37 views

test class not covering the controller class code

I am new to salesforce with the test class i am facing problem please help. this is my controller which i am going to test. /******************************************************************* * ...