You need to sign in to do that
Don't have an account?
Zoom_V
Need some help with test code
I'm having trouble figuring out how to write test code for the following classes. They all seem very simple, but I'm a complete rookie to test code and am at a loss. I don't know if this will make sense to anybody but I wanted to see if I could get some help on these two classes :
public with sharing class Milestone1_TestProjectBuilder { public Integer numberMilestones { get; set; } public Integer numberTasks {get; set; } public void buildProject() { Milestone1_Project__c newProject = Milestone1_Test_Utility.sampleProjectActive('Sample ' + Datetime.now()); insert newProject; for (Integer i=0; i < numberMilestones; i++) { Milestone1_Milestone__c ms = Milestone1_Test_Utility.sampleMilestone(newProject); insert ms; for (Integer j=0; j < numberTasks; j++) { Milestone1_Task__c task = Milestone1_Test_Utility.sampleTask(ms); insert task; } } } }
and this one which are essentially just a field validation messages :
public with sharing class Milestone1_Move_Exception extends Exception{ public static final String ERROR_MILESTONE_ALREADY_ASSIGNED_PROJECT = 'A milestone you are attempting to move is already assigned to this project. Please review your selection and try again.'; public static final String ERROR_TASK_ALREADY_ASSIGNED_MILESTONE = 'A task you are attempting to move is already assigned to this milestone. Please review your selection and try again.'; public static final String ERROR_MILESTONE_COMPLETE = 'Milestone is Complete, the Task can not be moved'; public static final String ERROR_MILESTONE_HAS_SUCCESSORS = 'Top Level Milestone has successors and cannot be moved. Redirect those successors and try again.'; public static final String ERROR_MILESTONE_HAS_PREDECESSOR = 'Top Level Milestone has predecessor and cannot be moved. Remove that predecessor and try again.'; static testMethod void testConstants() { //Just a place holder test method for static constants on this exception class. system.assert(true); } }
As I'm sure you can tell, I'm a complete rookie to test code. I apologize for asking for help on this and not being able to at least give some. Thank you very much for your help and time.
Hi Zoom_V,
since you are new to writing test methods i would first recommend you read this blog. http://jessealtman.com/2013/09/proper-unit-test-structure-in-apex/
Jesse does a great job in breaking down how and why tests are important.
Post back if that doesn't help get your test classes resolved.
Code The Cloud
Thank you very much. I'll do that.