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)

1
vote
3answers
29 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
41 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
96 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
37 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
25 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
52 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
27 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
83 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
48 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
46 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
31 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
27 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
31 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
24 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
25 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
49 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
60 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
26 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
54 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
154 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
22 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
52 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
29 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
68 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
50 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
2answers
43 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
98 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
53 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
65 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
46 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
62 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
31 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
17 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
44 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
66 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 ...
4
votes
0answers
24 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
96 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
15 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
55 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
40 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' ); ...
1
vote
1answer
32 views

Unit Testing a Trigger

Here is the piece of code for a trigger that I need to break into unit tests. I was thinking that I could begin by testing the most further in if statements as one unit test and make an additional ...
4
votes
3answers
124 views

Test Apex Code: How to emulate a SOQL call that has a related object?

For Apex testing, I'm trying to create an object that is the same as the one created with a SOQL statement (see following method). The method retrieves the Quote_To_Lease__c object from Salesforce ...
0
votes
2answers
98 views

Help me out with Apex Test class for the Apex trigger

Can any one help me out with this Test class written for this trigger is right or wrong.The Test class get saved but unable to see the code coverage. Here is the Code for the TRIGGER : trigger ...
3
votes
1answer
42 views

Programmatically Create Record Type

Is it possible to programmatically create a record type in Apex to be used in a test?
0
votes
1answer
28 views

Test Class to verify fields updated the same as the expected output

I'm creating my first test class got stuck with this one could you help me verify and correct the line of code for me. //Create a new record for Address Object with Local record type ...
-2
votes
1answer
39 views

variable doesn't exist [duplicate]

I was getting too many soql queries, so decide to split the unit test. Now i am getting the error variable doesn't exist:rtmap @isTest(SEEALLDATA=true) public class test_createCaseFromOppt { ...
2
votes
2answers
295 views

Compile Error: Method does not exist or incorrect signature: Test.startTest()

I am experiencing something weird on the Sandbox with all the test classes. whenever I run a test class I get the error: Method does not exist or incorrect signature: Test.startTest(). I am ...
2
votes
0answers
25 views

Async Callout Test Failing in Production

Situation I have implemented an API to communicate with the external system. After 18th of August test that i have on production have started failing showing the infamous: ...