You need to sign in to do that
Don't have an account?
westofoxley
Unit Testing - No idea how to do it??
Hi Can someone please help me write a test so I can deploy an APEX class.
I had to edit some previous code that someone wrote and I am try to learn APEX and Force and read some articles on testing but don't have a clue on how/ what to test in my code. Coming from a web designer background you just test it in the browser and it's all good.
public with sharing class EventListsStates { private static string prodId; private static string noRows; public EventListsStates() { prodId = ApexPages.currentPage().getParameters().get('prodId'); noRows = ApexPages.currentPage().getParameters().get('noRows'); noRows = (noRows == null || noRows == '') ? '5' : noRows; } public Campaign campaign {get ;set ;} public list<Campaign> upcommingEventsNSW {get { if (upcommingEventsNSW == null) { upcommingEventsNSW = new List<Campaign>([Select Name,Opportunity_Category__c,Event_Date__c,Venue_Name__c,Event_Month__c,Event_Day__c,Address_Details__c, StartDate, Running_Times__c, Product_Name__c, Location__c, IsActive From Campaign where Location__c = 'Sydney' and startdate >= today and IsActive = True and Publish_on_the_web__c = true and Product_Name__c = :prodId order by startDate ASC limit :integer.valueOf(noRows)]); } return upcommingEventsNSW; } set;} }
Thank you!!
Joe
Hey West,
go for this link , you will definetly ge an idea for the test classes
http://abhithetechknight.blogspot.in/2013/10/salesforce-test-class-basics.html
All Answers
Hey West,
go for this link , you will definetly ge an idea for the test classes
http://abhithetechknight.blogspot.in/2013/10/salesforce-test-class-basics.html
Hi Abhi,
Thank you for the post I passed the test using the following code. I'm not sure if it is correct but it seemed to work. I now will try to deploy it. Will Salesforce know that it has passed the test, will it embed that in the meta data? Anyway here is the code that I used for the test.
Your code is just perfect ,.....yes you can deploy it.
mark that answer as correct for other peoples.