You need to sign in to do that
Don't have an account?
MileageTracker Negative Test Case
Hi,
I posted this in the newbies forum too. Apologies if I have broken any protocols but I am really stumped with this and as you may imagine, when learning a new technology it is quite important that any examples work as expected.
The problem I have is that I don't know if it's something I have done or simply because the negative test cases doesn't work in the example?
First of all here is the code I'm talking about - it's in the testing section of the MileageTracker - Negative Test Case.
static testMethod void runNegativeTestCase() { System.debug('Inserting 501 miles... negative test case'); Mileage__c testMiles3 = new Mileage__c(Miles__c = 501, Date__c = System.today()); try { insert testMiles3; } catch (DmlException e) { //Assert Error Message System.assert(e.getMessage().contains('Insert failed. First exception '+ 'on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, '+ 'Mileage request exceeds daily limit(500): [Miles__c]'), e.getMessage()); //Assert Field System.assertEquals(Mileage__c.Miles__c, e.getDmlFields(0)[0]); //Assert Status Code System.assertEquals('FIELD_CUSTOM_VALIDATION_EXCEPTION', e.getDmlStatusCode(0)); } }
The problem I have is that when I run the test I get the following - see linked image...
Thanks in advance for your help.
Kind regards,
Ian
Ok, so not sure why I couldn't post an image but here is a link to the image showing what I see in my Force.com IDE...
Error Example
Thanks.