You need to sign in to do that
Don't have an account?

can any one can help for this?
I am new to salesforce, Could you please help me to write test class for below code
for(Release__c rel : releaseLst){
for(Material__c mat : rel.Materials__r){
if(mat.Material_Status__c == 'Draft' && Date.TODAY() < rel.Internal_Announce_Date__c && mat.Format_Description__c != null){
if(mat.Format_Description__c != 'EST (ELECTRONIC SELL THRU)' && mat.Format_Description__c != 'DVD RENTAL' && mat.Format_Description__c != 'BD RENTAL' && mat.Format_Description__c != 'VOD' && mat.Format_Description__c != 'HD VOD'){
if(rel.Street_Date__c != null){
mat.Street_Date__c = rel.Street_Date__c;
}
if(rel.First_Theatrical_Date__c != null){
mat.Theatrical_Release_Date__c = rel.First_Theatrical_Date__c;
}
if(rel.Internal_Announce_Date__c != null){
mat.Internal_Announce_Date__c = rel.Internal_Announce_Date__c;
}
if(rel.Trade_Solicitation_Date__c != null){
mat.Trade_Solicitation_Date__c = rel.Trade_Solicitation_Date__c;
}
if(rel.In_Plant_Date__c != null){
mat.In_Plant_Date__c = rel.In_Plant_Date__c;
}
if(rel.Pre_Order_Close_Date__c != null){
mat.Pre_Order_Close_Date__c = rel.Pre_Order_Close_Date__c;
}
for(Release__c rel : releaseLst){
for(Material__c mat : rel.Materials__r){
if(mat.Material_Status__c == 'Draft' && Date.TODAY() < rel.Internal_Announce_Date__c && mat.Format_Description__c != null){
if(mat.Format_Description__c != 'EST (ELECTRONIC SELL THRU)' && mat.Format_Description__c != 'DVD RENTAL' && mat.Format_Description__c != 'BD RENTAL' && mat.Format_Description__c != 'VOD' && mat.Format_Description__c != 'HD VOD'){
if(rel.Street_Date__c != null){
mat.Street_Date__c = rel.Street_Date__c;
}
if(rel.First_Theatrical_Date__c != null){
mat.Theatrical_Release_Date__c = rel.First_Theatrical_Date__c;
}
if(rel.Internal_Announce_Date__c != null){
mat.Internal_Announce_Date__c = rel.Internal_Announce_Date__c;
}
if(rel.Trade_Solicitation_Date__c != null){
mat.Trade_Solicitation_Date__c = rel.Trade_Solicitation_Date__c;
}
if(rel.In_Plant_Date__c != null){
mat.In_Plant_Date__c = rel.In_Plant_Date__c;
}
if(rel.Pre_Order_Close_Date__c != null){
mat.Pre_Order_Close_Date__c = rel.Pre_Order_Close_Date__c;
}
Create a test apex class, declare Release__c and Material__c objects, fill all the conditions given in if loop, insert the records. Now call the Apex method in the test class. Check for code coverage. Simple....
If you cant understand let me know i will post the code. Before making reply try by yourself.
Thanks & regards
SAGA BJ