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

Mock Unit Test for a REST API callout

After attending DF14 I have a fairly solid understanding of the HttpCalloutMock() when unit testing for REST callouts, but I'm having trouble implementing it for the first time. The documentation I've ...
6
votes
2answers
47 views

Best Design for an easily maintained Unit Test?

I'm attempting to design a Unit Test Utility that we can use across our 15++ UE Orgs. I'm aiming to accomplish the following goals: Reads from a declaratively-maintained map of required field/values ...
4
votes
1answer
142 views

How is the Test Code coverage required for deploying calculated?

Would like to Know- suppose we've sandbox from which we deploy to production. There is already set (A) of classes, some of whose test classes are failing Now we want to deploy Different set(B) of ...
4
votes
2answers
59 views

Test Class SeeAllData=true Annotation

I am creating a test class that will test my controller class which uses almost 5 to 8 objects that has many DML statements like insert and delete, however I am feeling a little bit worried about not ...
2
votes
1answer
16 views

Constructor not defined error when deploying to production

i'm getting a bit lost in the weeds with the error I'm getting when trying to deploy this simple test class to production. In the sandbox, it compiles fine and runs fine test-wise, but when it comes ...
0
votes
1answer
50 views

Please help me with below test coverage

I have below trigger. And i have one test class. Trigger is Covered 76%. i want to make it more than 90%. The code which is not covered is at line numbers : For Trigger 1 :14,17,25,26,27,32 For ...
3
votes
1answer
22 views

Tool for check valid test cases in Salesforce?

We have a existing project which has a number of invalid test cases - which means, test cases only have the code coverage but don't have system.assert in it. I remember there is a tool to find those ...
0
votes
2answers
34 views

Increase test coverage for query IsSandbox =true

I am checking for sandbox with help of query select Id from Organization where IsSandbox =true limit 1 but now in production and developer org my code coverage is going down to 33% as this query is ...
1
vote
3answers
37 views

Unit test for trigger SOQL query that is uncovered

I'm having an issue finishing up my unit test, and I think it is related to the SOQL query in my trigger. The trigger itself checks to see, upon Lead creation, if a Contact exists with a matching ...
0
votes
1answer
15 views

Test Class to cover NotesandAttachment

I am creating one test class to cover this query.The query is covered, I tested one value retrieved but it does not go into for(NoteAndAttachment h:actOpen.NotesAndAttachments) loop. List< ...
2
votes
0answers
45 views

No test coverage on after insert trigger

I can't quite tell why code coverage is saying that there are 0 lines covered. My objective is that every time an Award is inserted, an Award Judging Criterion is inserted with a link to the Award. ...
1
vote
3answers
103 views

Problem with System.assertequals in test class code

I have below trigger code : trigger updateopportunities on Account(after update) { Set<Id> accountIds = new Set<Id>(); for(Account ac : Trigger.new) { ...
2
votes
1answer
40 views

Cannot use @istest in Apex Triggers

I'm brand new to Apex/Salesforce development, and am attempting to create some Apex triggers and tests. Each time I try to add a new class, when I start it with @IsTest I am unable to save it. I see ...
1
vote
1answer
28 views

Help Creating a Test Class for a VF Controller

Apex newbie here and would really appreciate the help on a test class I'm trying to write. Basically, a VF page called "Invoice" is getting created when a button is pressed on the Quote object. The ...
2
votes
2answers
60 views

Test class Standard price book entry error STANDARD_PRICE_NOT_DEFINED

i got error in my test class. System.DmlException: Insert failed. First exception on row 0; first error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: [] my test ...
0
votes
0answers
29 views

System.TypeException: Methods defined as TestMethod do not support Web service callouts, test skipped

we have written trigger for echo-sign object, after updating object through our trigger, echo-sign code calls @future method from their managed package. this future method has webservice callout. Our ...
0
votes
3answers
88 views

Apex test 3% code coverage,

Need Help! I have a test class GoogleMap_Meeting_Controller_Tester with 3 objects, location(master), groups(child) and meeting(grand child). The SOQL query is returning a rowthe Apex coverage is still ...
-3
votes
2answers
54 views

Help with Code coverage, Loop and if conditions

I'm unable to have code coverage. Wrote a test class that has 24% coverage. How should I test loops and conditional statements? Following is my Apex Class... public class OrderTrackingList{ ...
0
votes
1answer
47 views

Test class is not full coverage

Here is my apex class and Test class: Some of lines are not covered in the class, i'l mentioned -------- like this. Apex Class: public with sharing class TaskController { private ...
1
vote
1answer
33 views

Help with controller test class. First Attempt! [duplicate]

It's my first take on writing Test Class. Following is my Apex Class... public class OrderTrackingList{ public OrderTrackingList(ApexPages.StandardController controller) {} public ...
3
votes
1answer
38 views

How to achieve Test Coverage for Interface Classes

I am using the trigger framework presented here, which uses several interfaces and utility classes: ...
2
votes
2answers
29 views

System.JSONException in Salesforce Test Class

I got error in test in this condition. while (parser.nextToken() != null) { if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && (parser.getText() == 'periodName' )) { ...
1
vote
3answers
36 views

Write test class for webservice callout in apex class

I have one apex class in which I am calling one webservice of one of my managed package installed in my org. When I am writing the test class for my apex class, it is throwing the error callout ...
2
votes
1answer
28 views

How to create object by it's name?

I'm writing a REST service which calls external service. I want to write a test for my service. I came up with no possibility to mock this call as it's in managed package. I want to wrap this call ...
0
votes
1answer
27 views

Need Code Coverage for CRUD If Block, How can I achieve that?

Here is my Controller Code --- // creates a new Attachment__c record Attachment__c objAttach = new Attachment__c(); private Database.SaveResult saveCustomAttachment() { ...
2
votes
1answer
58 views

How does one test Visualforce components with custom controllers

I have created a custom Visualforce component. It is backed by a custom controller. I am struggling to write unit tests for it. The limited VisualForce documentation indicates that to test it I ...
-1
votes
1answer
65 views

How to write down test class for If else condition

Scenario: If First name or Email or both missing from existing contact then error message should be display. ................ Apex class controller if(contact.Id !=null && contact.Email != ...
2
votes
1answer
30 views

Unable to create ConnectApi test data

I'm stuck trying to write a test method for the ConnectApi. Specifically, I have a remote action that uses the ConnectApi.QuestionAndAnswers.getSuggestions() method, which returns related (Chatter) ...
7
votes
1answer
58 views

Unit testing complex workflows

I'm working on a project that entails refactor of a lot of complex workflow rules. I was wondering if anyone here writes unit test to test their workflow rules? Seems like it would be a good idea ...
2
votes
1answer
158 views

Which is more recommended, test classes or inline test functions?

So up until now every time I make an apex class, I make a separate class that tests that class (usually the same name with the suffix "TestClass"), which is what I've seen a lot of people do. However ...
0
votes
1answer
24 views

How to write unit tests for a post install script?

I'm trying to write a unit test for a post install script class, a class that implements InstallHandler interface. I'm testing two cases: 1- No previous version is defined, for that I just use this: ...
1
vote
1answer
54 views

code coverage for the test class

i have a batch class which i am scheduling for run. and i have a test class for the batch class. the batch class is working fine . but the code coverage is 44% . important note: when the batch ...
2
votes
1answer
30 views

Not enough coverage for Apex utility Class, although COLLECTIVELY my unit tests cover everything

I've moved a lot of my trigger code over into class methods so I can control what order the logic happens in. Each object has one Trigger like this, and each Trigger may might call up to a dozen ...
-3
votes
1answer
80 views

System.NullPointerException: Argument cannot be null. in Test Class

At this line I am getting an errror, while running a Test Class, Please suggest solution - public PageReference Save(){ -------code ------ Object__c obj = new Object__c(); ...
0
votes
1answer
59 views

batch class execute() method not covered by test class

Need to raise the covered line on this apex code could you kindly point out the missing piece of code for my test class. It does not covered the code in bold face (global void ...
0
votes
3answers
58 views

I need help writing a test class

I have written the below trigger and helper class. I am a newbie and pieced the trigger and class together with help from various forms. It works fine in sandbox but I have no idea how to write the ...
0
votes
1answer
123 views

visualforce Page reference custom controller test class

I have visualforce page that using custom controller. page have section to save record to my custom object. <!-- ...
1
vote
1answer
59 views

Test Apex Class Error: Error: Compile Error: Expression cannot be assigned at line -1 column -1

I am playing around SFDC and wrote a trigger to count the total Contacts in the system. I wrote the test class and when I am trying to save the class I get the following error: Error: Compile ...
1
vote
0answers
74 views

error from test method - “apex job is already scheduled for execution”

I have a batch apex which starts itself after x mins. this is done in finish() method using , system.scheduleBatch() method. below is how the batch looks like, global class my_ProcessPurge_Batch ...
0
votes
1answer
48 views

Test class coverage for Exception

I have below code to coverage : public static list<Contact> getContactsByAccountId(Id accountId, Id contactId){ try{ return [SELECT Id, firstName, LastName, Email, Phone ...
1
vote
1answer
64 views

Linking a contact to user

I am trying to link a contact to a user object in test case. However, it seems that user.contact = contact doesn't work and user.contactId = contact.id will cause an error saying contactId field is ...
1
vote
1answer
34 views

Missing FolderId in Chatter Trigger Test Class

We created a trigger and test class: when a new record under Keyword object is created, we want an email notification sends out automatically to record owner and confirm we receive his keyword ...
0
votes
1answer
20 views

How to create OpportunityPartner object to test OpportunityPartner functionality?

I want to write some tests to check a logic, related to OpportunityPartner object. The logic reads OpportunityPartner for Account, then reads it's Contacts. partners = [ SELECT OpportunityId, ...
0
votes
2answers
46 views

Test class for new case controller

I've recently been writing a few basic controllers for some visual force pages, and of course now need to test them. Problem is I don't really know how. Normally you know you'd instantiate the class, ...
5
votes
2answers
67 views

Relationship returning null in unit test

In a unit test, I'm having a problem where values spanning relationships are blank. I have a custom field, Quote.My_Formula_Field__c, which is defined as Opportunity.Lookup__r.Name, which is used in a ...
5
votes
1answer
30 views

Confirmation that certificates can't be created in unit tests?

I have some Apex code that uses: Crypto.signWithCertificate('RSA-SHA256', Blob.valueOf(token), 'CertificateName') and ideally would like to be able to create a named certificate in the unit test. ...
0
votes
3answers
100 views

Issue with Code coverage during deployment

Hello I am trying to deploy a Trigger and a Class from my Sandbox to production environment. I am running into Code coverage error. The code coverage when i look in the developer console says is 75% ...
0
votes
0answers
19 views

Writing test cases for Salesforce sdk hybrid_local applications

I want to write test cases for my salesforce sdk hybrid_local applications. I use angular js. After some reading figured out that Jasmine, Karma(unit tests) and Protractor (end to end tests) are the ...
0
votes
3answers
74 views

Unit testing a trigger - expecting right curly bracket, found 'insert'

I am creating unit tests to test a trigger that makes a calculation with particular variables depending on the value of a different. I believe the code below is correct, however I cannot figure out ...
0
votes
1answer
42 views

Deployment error while deploying

Apex class: public void post(){ HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); req.setMethod('POST' ); ...