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 (2)

0
votes
1answer
13 views

Inserting Test.loadData in into Salesforce DB for tests

I am able to load the static resource but I am unable to insert the loaded accounts into salesforce. I want to do this to be able to test various methods that depend on first selecting a particular ...
0
votes
1answer
21 views

Invalid Cross Reference Key : Record Type ID value isn't valid for User: 012v00000008f4nuBB

I am having some issues. The below is a code snipet of my test class. The class complies and produces 96% of coverage with no errors. When deploying in production it throws the above error. ...
0
votes
0answers
22 views

Test class assertion failure and test coverage issue [on hold]

I am getting below error message. while running test class. System.AssertException: Assertion Failed Class.CommunityNewsTest.SnapshotTest: line 35. **this is line 35 ** ...
0
votes
0answers
16 views

test class and coverage issue

Test class and coverage issue . Getting only 50 %. .... @isTest public class CommunityNewsTest { public static testMethod void testTableRecords(){ for(Integer i=0;i<10;i++){ ...
3
votes
1answer
26 views

System.VisualforceException: Invalid value for property label: null

Sigh. So I am required to cover my Apex code with tests. I'm testing a piece of code that dynamically builds a tree of controls with a PageBlock as the root object. This code works fine when NOT ...
2
votes
1answer
18 views

Speedup Testing with Force.com IDE using slim Logs - but how to set the log-level?

A lot has been written here about slow development in general and slow testing in particular e. g.: Slow development Faster unit tests? For my use case I found one reason for slow testing while ...
-1
votes
1answer
31 views

Apex Testing - Best Practices [closed]

A general question asked from time to time on stack exchange is how to implement tests. There are some general questions to ask: What are your testing best practices? Thanks for sharing your ...
1
vote
1answer
14 views

Production Test Execution “Could not run tests on class …”

While running my test cases within my prod environment, I noticed quite a few messages as the title describes, and I don't understand why. Do you have any insight on why this is happening? It seems to ...
1
vote
1answer
98 views

Can some help me get coverage for the below trigger?

Trigger: Trigger copyEquipmentonsite on Unit_Placements_Sales__c(after insert, after update) { List<Services__c> sub=new List<Services__c>(); for(Unit_Placements_Sales__c u : ...
1
vote
1answer
47 views

Unit Tests max number of test methods in a class?

I have many unit test methods (30+) in a test class that cover my class well - setting up data, setting the page and controller, calling methods and setting properties, doing asserts. But when I look ...
1
vote
1answer
29 views

Test for sendEmail() error

Hi I have built a class and a test and I am getting close to getting the test to work. I am trying to send an email using a template. But I am getting an error on the last line of code. Save ...
0
votes
2answers
35 views

How to call action function method in the test class

How do I call a method in my test class which is basically been called from the action function on the vf page? VF page: <button type="button" onclick="myJSMethod();">my button</button> ...
0
votes
1answer
18 views

Performing an Upsert in PageReferenceSave - Not updating Item.ID for Use In UnitTest

I have a test that creates a new record in our custom table - Service Offered. Whe I call my controller and save - It creates/updates the record correctly, and in my class the Debug.Assert gives me ...
3
votes
1answer
56 views

How to mock a SOQL query in Apex

Our Apex unit (true integration) test run takes about an hour to complete (260+ individual unit tests) and this really slows down our dev process as we are trying to adhere to Continuous ...
0
votes
0answers
42 views

Insert contact statement in test class is causing 0% code coverage

I've written a simple trigger to prevent duplication of a lead based on existing leads and contacts. My test has 90% code coverage based on the tests that I've written to prevent lead duplication. ...
1
vote
1answer
33 views

How to access recordType in Test Methods with seeAllData = false

I am writting a test method for a certain code.This code is fetching Record Type detail from an Object Service_Form__c. Class: String recordTypeName; Schema.DescribeSObjectResult srfDescribe = ...
0
votes
1answer
28 views

How do I write a test class for the below trigger? [closed]

I have just created the below trigger that is deigned to create a new custom object record(Services) when a custom date field (Service_Date__c) on another custom object (Unit)is equal to "This Month". ...
3
votes
0answers
56 views

Unit Test: You have uncommitted work pending. Please commit or rollback before calling out

So I have a method that takes as a parameter an Id of a object and uses it to make an external callout. Unfortunately I can't seem to figure out any way to test it. @isTest static void ...
2
votes
2answers
29 views

Testing code where maintenance tables are involved

I suppose this is more of a general programming question than a strictly Salesforce question. I have a trigger which clones / creates new record when criteria fits the match: trigger cloneObj on ...
4
votes
2answers
95 views

Scheduling Run All Tests

is there a simple way to schedule the run of all test classes? I want to avoid having to do this manually every day. Thank you!
2
votes
1answer
27 views

Test Class is not working for Map in class

I am not able to get coverage for the Maps in the class. I only getting 54% coverage and don't know what else to try. Can anyone please help me here. I will truly appreciate it! public with sharing ...
0
votes
2answers
28 views

Inserting test data using a list or a map to reduce the number of DMLs and get different Ids for different tests

Refer to below test class, @isTest public with sharing class CategoryHelperTest { private static boolean testDataCreated = false; private static Scheme__c ss; private static ...
0
votes
2answers
58 views

Apex Test Class - After Update Trigger

I have a test class that is only covering my trigger 48% and I want to get it as close to 100% as possible. It appears there is one section that I am not covering when using the Developer Console but ...
0
votes
2answers
42 views

Problem in System.assertEquals method [closed]

I am writing test class in which I'm inserting 5 custom objects. My question is that do i need to add System.asertEquals for each and every object or to add to any one is sufficient.
0
votes
2answers
19 views

Inserting test data using a list to reduce the number of DMLs

I got the below test class, @isTest public with sharing class CategoryHelperTest { private static boolean testDataCreated = false; private static Scheme__c ss; private static ...
2
votes
1answer
217 views

How to write test coverage for private method in controller?

How can I test private methods in an apex controller ? For instance this example: private static string getUserId(String str){ string UserId = ''; if(ref != null){ ...
0
votes
1answer
27 views

Does anyone recognize this error message pop up in Salesforce?

I'm trying to run some tests in the Salesforce 'Apex Test Execution' page and suddenly this error message has popped up, it keeps appearing when I press the 'Select Tests...' button. Has anyone seen ...
1
vote
1answer
69 views

System.NullPointerException: Argument cannot be null

Im getting the error 'System.NullPointerException: Argument cannot be null' when I run my test class, in the below test method. /* * update a existing report */ static testMethod void ...
0
votes
1answer
38 views

test class is not covering email messaging

trigger: trigger TaskCompletion on Task (after insert,after update){ IF(trigger.isinsert){ for (Task E : Trigger.new){ If((E.CreatedById != ...
0
votes
0answers
35 views

Help regarding test case code coverage

public with sharing class searchpn { //variables Public Id parentId; public Integer qliRowNum1{get;set;} public Integer qliRowNum{get;set;} public Integer finalRowNum{get;set;} ...
1
vote
3answers
93 views

0% code coverage Test APEX class

I have set up a simple APEX class that is an extension for a Visualforce page. The VF page has a commandButton that saves and takes you to a different page called "Congratulations.vfp" I have been ...
1
vote
1answer
41 views

APEX Unit tests hello world

I am trying to learn how to do APEX testing but all the tests in the documentation are too complex and I can't find an example of a simple APEX Controller that is a Hello World Test. I have this APEX ...
2
votes
1answer
42 views

How to use Pattern matching in test class for email field?

I am using pattern matchers for the email filed in contact in my development. When writting the test i am getting error in that patter matches.Here i have method the error line.Kindly help me to ...
-2
votes
1answer
45 views

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING in test class

Class: public class CreatePurchaseorder{ public Purchase_order_setting__c pos {get;set;} public boolean isInput{get;set;} public id poid{get;set;} public boolean isUpdt{get;set;} ...
4
votes
0answers
61 views

Creating Idea Votes from portal user in Test code. DML Exception

I Wrote a very simple VF Page and Controller to show the Accounts that voted on certain Ideas. Here is the controller. Just aggregates the Up and Down votes on the Idea excluding internal votes. ...
-1
votes
0answers
33 views

sales force test class

i wrote one class and for that test class also created.. class: public class FRsubPrjCtrl{ Public Project__c pln{get;set;} public Allocation_amount__c sub; public ...
0
votes
2answers
30 views

VF Controller Test Class

I have been trying to create a test class for my controller for my visual force page and I am not grasping the concepts behind it, can someone help me get started? I have tried a few things but I have ...
2
votes
1answer
53 views

I have this trigger and test class . why my test class cover 0%

trigger openTrigger on Project_Item__c (after insert,after update,after delete,after undelete) { Project_Item__c[] items; //Use Trigger.old For After Delete and The Others is Trigger.new ...
0
votes
0answers
62 views

Incorrect code coverage in developer console

I have an apex class called RelationshipTreeController (RTC for short) and a test class called RelationshipTreeControllerTest (RTCT for short). I have written a test method that calls the search() ...
1
vote
1answer
30 views

Need help for custom controller test class

i implemented chatter check in for this blog: http://intmist.wordpress.com/2014/03/23/show-custom-visualforce-page-in-salesforce1-setup-publisher-action-and-check-in-using-salesforce1-app/ do some ...
0
votes
2answers
40 views

how to write a test for read only Page

I have a page emitting XML for outside users. All it does is create xml from the data. I have a problem writing a test to cover it. The page is just: <apex:page showHeader="false" ...
2
votes
1answer
55 views

Passing related objects in tests

I have the following visualforce page: <apex:page standardController="Whatever__c" extensions="WhateverExt" action="{!autoRun}"> <apex:form > <apex:outputField ...
1
vote
2answers
70 views

How can I generate debug logs when I run unit tests from MavensMate?

Generating and viewing debug logs in MavensMate has been clarified before and works great for me - I especially like the Scrub feature. However, I can't generate a log when I run unit tests. To ...
0
votes
1answer
29 views

Test Method to check the error message is displayed in a certain scenario

I got this test method written, static testMethod void test_ValidateImpactCategories(){ Test.startTest(); tester(); ic8 = new Category__c(Name = 'HR',Symbol__c ...
0
votes
1answer
45 views

Getting error CANNOT INSERT UPDATE ENTITY

can anybody help me here. I am not able to push a trigger into production, I am getting this error for all the test.classes. I hope someone can tell me what is wrong here. I will appreciate any help. ...
1
vote
1answer
28 views

Help writing test class for trigger

I need help writing the test class, I am getting only 70%, I don't know what else to do. I will appreciate any help! Trigger Code: trigger updateOSOTrigger on SO_Detail__c (before insert, before ...
2
votes
1answer
48 views

TestMethod SeeAllData defaulting

I have a question about the two examples shown below as it seems that a testMethod defined within a standard class defaults SeeAllData to true whereas when the test method is defined in a separate ...
1
vote
1answer
24 views

Can't resolve 'Method does not exist' error

I have a Controller, roughly as follows: global with sharing class MyController extends OtherController { public static List<Task> getTaskList() { //SOME LOGIC ...
2
votes
2answers
35 views

Sharing Sets and Apex Test Code

Im trying to setup a simple test to show the "sharing set" is working properly. I a communities sharign set that says Account | User:Account = Account:Id | Read/Write and I know this works ...
1
vote
2answers
236 views

How do you test a class that only pulls data

I'm confused by this. When I was using a dev account it allowed me to create classes in Apex Class like this and deploy it with no problem, but now that I'm using our real account it won't let me ...