I m trying to cover and test my apex code so I developped a test class to test my insertion, my the test is failed unfortulately; and gave me this error: Assertion error
here is my test class:
@isTest
private class TestTimeOff {
static testMethod void myTimeOffTest() {
Test.startTest();
Time_Off__c to = new Time_Off__c();
to.Start_date__c = Date.newInstance(12, 05, 2015);
to.End_date__c = Date.newInstance(13, 05, 2015);
//to.My_back_up__c = 'XXXX';
to.Pattern__c = 'Payed time off';
to.Comment__c='My Class Test';
try{
insert to;
}
catch(System.DMLException e){
System.assert(e.getMessage().contains('Insertion failed'));
}
test.stopTest();
}
}
an other problem; My_back_up__c is a reference to a user, how can I do this? should I give the user ID??
p.s. I have trigger launched before and after adding a Time Off
Thank you