You need to sign in to do that
Don't have an account?
Abby Stocker
Help with test class!
I have received some pretty awesome help from here correcting my code so I figured I would try to see if anyone can help me write a test class. My training (newbie) on test classes so far only include validating if statements, creating accounts with field values populated etc.. Help! Thank you!!! The 2 classes are for this purpose : Code 1 is looking for the id of the current case record. Code 2 is looking for the task id's associated with that current case record.
Code 1
public class currentCaseRecord {
Case currentRecord;
public currentCaseRecord (ApexPages.StandardController controller){
currentRecord = [Select Id FROM Case Where Id =:ApexPages.CurrentPage().getparameters().get('id')];
}
public case getcurrentRecord(){
return currentRecord;
}
}
Code 2
public class RelatedTasks {
List<Task> tasks = [SELECT id, subject from Task WHERE WhatId =:ApexPages.CurrentPage().getparameters().get('id')];
}
Code 1
public class currentCaseRecord {
Case currentRecord;
public currentCaseRecord (ApexPages.StandardController controller){
currentRecord = [Select Id FROM Case Where Id =:ApexPages.CurrentPage().getparameters().get('id')];
}
public case getcurrentRecord(){
return currentRecord;
}
}
Code 2
public class RelatedTasks {
List<Task> tasks = [SELECT id, subject from Task WHERE WhatId =:ApexPages.CurrentPage().getparameters().get('id')];
}
* First you need to make some change in you controller class and make it using best Practices to make classes
Controller class----->
Controller Class------>
Test Class------>
* Code coverage is 100% for both controller classes
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com