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
0answers
15 views

Unit Tests run when installing unmanaged package?

When installing an unmanaged package will the unit tests run? We're working with a partner that installed a package (I can see it in Setup | Installed Packages). The package has no namespace prefix ...
-1
votes
1answer
28 views

After delete trigger SOQL returns no rows

I need help I'm losing my mid. I have a working trigger and I'm writing a test class. My data is isolated ( no @seeAllData=true) I create a master and children objects in my set up. I insert the ...
3
votes
0answers
32 views

Package test coverage way lower than actual

So pretty much what topic says. While trying to upload a package I get the following error: However, when I check test coverage anywhere else, it shows me 77%. Developer console: Setup --> ...
-1
votes
1answer
27 views

Test class covers only 50% of trigger

@istest public class beforeinserfieldnewobj_TC { static testmethod void beforeinserfieldnewobj() { account a=new account(description='xxxx'); insert a; contact con=new contact(); con.lastname=a.name; ...
0
votes
1answer
22 views

writing a test class for a trigger [on hold]

I have a trigger: public static list<Opportunity> createRenewalOpps(list<Policy__c> newPolicies, map<Id, Opportunity> mapRealOpps, Map<Id, Account> accountsMap){ ...
3
votes
1answer
45 views

How to query for formula fields in test classes

From what I understand, formula fields are calculated when a record is opened/read. If a record is created by a controller extension and then queried then it's never really opened or read, so ...
1
vote
2answers
36 views

Schedule Class does not reach 100% coverage

I created a schedule class to run an update for all leads created 5 days ago On the test class, I do create a lead BUT I can't set the scheduler to run 5 days AFTER the lead was created (Today + 5 ...
0
votes
1answer
15 views

Why Batch can't work in unit-test? [duplicate]

There are 2 methods will callout and insert.I wrote 2 batches to invoke my method. I use the one invoke the other one to avoid System.CalloutException,and it's useful when i run them. global void ...
0
votes
2answers
33 views

Unit Test coverage problem help me to resolve this [closed]

This is the Class where I am facing the problem public class SaveMultiObj { public humanresource__c hr{get;set;} public CandidateHr__c cand{get;set;} public AdminService__c ...
0
votes
1answer
27 views

Unable to call controller extension method from test class

I have a custom object which is a child to the Opportunity object. The custom object is viewed via visualforce page. Sometimes Users need to create payment records for the child object. This is ...
3
votes
1answer
32 views

Code Coverage Query

A simple scenario (I) Let us assume I have 3 classes A,B,C. Each class has 100 lines on them. Total Number of Apex lines written (for simplicity sake let us assume that none of the 300 lines are ...
2
votes
1answer
45 views

How to write the test class for Pagination

Can anyone tell me how to write the test class for pagination? Below is my test class which covers 85% but it didnt covers the hasnext,previous and pagenumber method. Test Class ...
1
vote
1answer
33 views

How to test callout in batch

I'm trying test a critical part of an application that is in a batch process and makes callouts to a server. MyObject__c obj = new MyObject__c(name='test'); insert obj; Test.startTest(); ...
1
vote
2answers
48 views

Bind Variable Issue with SOQL Query in Test Class

I'll admit outright, I'm a beginner when it comes to Apex, so I apologize if anyone's addressed this already or if I'm missing something obvious, but: I'm trying to write a test class to cover my ...
0
votes
1answer
19 views

How to compare two lookup field in system.AssertEquals

I have an object Timecard ( pse__Timecard_Header__c ) inside which there is a field called Period__c. I have another object Period (c2g__codaPeriod__c). In system.assertEquals I want to compare these ...
0
votes
1answer
24 views

Can we use system.assert followed by system.assertEquals?

pse__Timecard_Header__c th1 = new pse__Timecard_Header__c( CurrencyIsoCode = 'USD', pse__Project__c = project.ID, pse__Resource__c ...
2
votes
1answer
36 views

Salesforce Test Class for APEX Trigger

I'm in need of some help regarding the writing of test script that covers enough of the below trigger that I have managed to get working on my Sandbox account. The trigger is to automatically fill ...
-2
votes
2answers
33 views

Unit Test code coverage problem on Controller Class Solved thanks every one [closed]

Here is the Controller where i facing problem public class RerenderEx { public contact con{set;get;} public boolean Abool{set;get;} public boolean Bbool{set;get;} public RerenderEx() { ...
0
votes
2answers
34 views

Unit Test code coverage problem

Here this is the class: public class relatedList { public account acc{set;get;} public contact con{set;get;} public string accname{set;get;} public void getdata() { ...
0
votes
1answer
26 views

Help me to Resolve this Unit Test

here is the my Class public class HrtoCandidateHrs { public CandidateHr__c c; public HrtoCandidateHrs(ApexPages.StandardController controller) { c=new CandidateHr__c(); ...
-1
votes
2answers
28 views

Help me Solve unit test

> Here is the class where i need unit test public class extCtrlEx { private final account acc; public extCtrlEx(ApexPages.StandardController controller) { this.acc=(account)controller.getRecord(); ...
1
vote
1answer
37 views

Help on apex Test Class.

Following is my apex class....The lines not covered are => marked public class OrderTrackingClass{ public class Order { public Orders__c sob {get; set;} public OrderLine[] orderLines {get; ...
0
votes
2answers
30 views

Unit Test Problem

My Test class not covering all the code in this class plz help me to resolve this Here it is my Class public class emailCon1 { public map<string,string> m{set;get;} public ...
1
vote
0answers
28 views

How would I create a unit test for this class?

As the title suggests, I am struggling with unit testing. This is the very first time I have create a unit test in SalesForce. How would I create a unit test for the following function? public with ...
0
votes
1answer
22 views

Unit test does not cover lines of after update trigger

Here it is the Trigger on Event Activity trigger eventHistoryChecker on Event (after update) { ///////// //This is the Trigger handles record updates from the Event Obj ///////////// ...
0
votes
0answers
13 views

Inconsistent behavior when retrieving fields in Apex Test Class

I've been experiencing a very strange issue I cannot explain when creating test coverage for my code. Typically I create all the hierarchy of objects that are involved in the test of a certain ...
0
votes
3answers
21 views

Problem on Unit Test class

This is the Class need help for writing Test Class below this is Test Class public class CaseCreateHelper { public void createCase(List<Account> accs) { //Store list of ...
1
vote
1answer
23 views

Trigger is not firing from Test Class

I have tried to search up on this for a while now but couldn't find any answer to my question... I have wrote a simple trigger that when an Account record is moved out of view (Moved out of view = ...
0
votes
0answers
18 views

Shared Activity TaskWhoRelations not working as expected

I am updating some of our triggers to work with Tasks and Events that have multiple associated Leads or Contacts. I was having some problems, so I wrote this test to test that they worked as I expect ...
-1
votes
1answer
61 views

How to write a test case for trigger?

I have two objects. 1. Timecard 2. Period I have a Trigger in which I am comparing Timecard month = Period month and Timecard owner company id = Period owner company id Here Timecard owner ...
0
votes
2answers
19 views

Testing problem with RunAs() and Schema isCreatable() method

I create a test method and I do not understand why the result is a failure. 1, we have a TestProfile Custom profile with create permission on Account object. 2, The next snippet of code run with ...
0
votes
1answer
23 views

Test Class - Opportunity Creation with If Statement

I've tried looking around for a situation matching my own as well as a lot of experimentation but I am at a loss. I've managed to write an APEX trigger to create a new opportunity if another ...
0
votes
2answers
35 views

Test Coverage for Batch Class

I have the following Batch class which operates on a custom object (Sample__c) and the default Contact object. My test class goal was to create a list of Samples which I know satisfy the batch's query ...
3
votes
2answers
53 views

Adding SOQL Query to untested Apex Class causes errors in other classes

I have been asked to manage a large salesforce organization and I am getting a strange error. I simply need to create a Visualforce Page and a Controller right now. I have been banging my head against ...
1
vote
1answer
47 views

Trouble w/ Developer Console and accuracy of test coverage

Thanks for the help yesterday. I have my trigger written and am now working on my test class. I am totally confused by the developer console and the testing process. Yesterday, my test results in ...
3
votes
1answer
56 views

Trigger/Workflow Rule Recursion on Opportunity and LineItem

We have a trigger on Opportunity that updates the OpportunityLineItem when the Opportunity is won. We also have workflow rules on the OpportunityLineItem that fire and this causes some recursion to ...
0
votes
1answer
22 views

code coverage on triggers [closed]

Please help me, its covering only 45%, i want to cover 100%. How will we do it? trigger DiseasesCountForDivisions on account (after insert,after update,after delete) { private Set<Id> ...
2
votes
0answers
27 views

System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out in test class

I am facing this issue in a MockCallOut for http in test class. I know that a dml is not allowed just above the callout, so I have tried to put callout between Test.startTest() and Test.StopTest(); I ...
-1
votes
2answers
40 views

Write Test class for custom controller having wrapper class that makes a HTTP callout [closed]

Hello All Can anyone please help me to write test class for my custom controller. Below is my custom Controller. public class InsertDataInToNewShopCtrl{ public InsertDataInToNewShopCtrl(){ ...
0
votes
1answer
32 views

Test class not cover when i use schedule class

I have used schedule in class for my code. I am not able to cover code 100%. Its just cover 64% even i have write all condition. Class public void execute(SchedulableContext sc){ Integer ...
3
votes
1answer
43 views

Test Class not covering the execute method

This batch class is to set the recordtype when it is null. global class ContactBatch implements Database.Batchable<SObject> { global String query; global Database.QueryLocator ...
2
votes
0answers
16 views

Is it still impossible to start a Flow Interview for a VisualForce Controller's Unit Tests?

Currently looking at An Advanced Example of Using Been writing some unit tests for the VisualForce controllers I've been creating, which, with my original code would result in "Interview not ...
2
votes
0answers
27 views

Run All Test Classes ( My Namespace vs All Namespace)

My Namespace : Only local classes that aren't from managed packages appear in the list All Namespace: All the classes in the organization appear, whether or not they are from a managed package. I ...
4
votes
0answers
45 views

deserializing JSON to object: different behavior in unit test vs API?

So let's say I've got a class that looks like this: public class APIParams { public String name; public String category; public Boolean taxable = false; } Then I have a ...
1
vote
0answers
28 views

Help with Apex code to test a triggers

I've have a child entity - Credit Application that is created on the parent entity - Lead(Appointment). After the child has been created, users go in an update information on the banks used for the ...
0
votes
1answer
37 views

How can I write a unit test which includes ApexPages.StandardController methods?

Currently looking at the Using Dynamic References with Custom Objects and Packages tutorial. For reasons I won't speculate on, step 7 included the controller extension code (again) instead of the ...
0
votes
1answer
27 views

Unit Testing Help

I've been reading up on Unit testing and I'm trying to get a test done for a class. I want to delpoy this to our live Org but am pretty stuck at this: The Code itself works but I've never done unit ...
3
votes
1answer
58 views

How can I test create an instance of a VisualForce Controller Extension for testing?

Typical of custom controller extensions, my extension has a signature public MyVFCtrlExt (ApexPages.StandardController standardController) I'm currently trying to figure out how to write unit tests ...
0
votes
1answer
30 views

Duplicate ids is test class execution

Following in my class. I get duplicate ids in test class execution. // Class public class CreateEmpData { public CreateEmpData() { } public static ...
1
vote
1answer
25 views

Unit Test for Report

I need to write unit tests to call a method that validates the content of a Reports.ReportResultsObject. Is there a way to create reports programmatically, execute them and use the ...