You need to sign in to do that
Don't have an account?
AkiT
Tests results "REQUIRED_FIELD_MISSING"
Hi,
I am trying to finsh test method for my controller but something is wrong.. I get "REQUIRED_FIELD_MISSING" on my upsert call.
I have created successfully test data and I am adding the id parameter to the page. Any ideas? below code...
I am trying to finsh test method for my controller but something is wrong.. I get "REQUIRED_FIELD_MISSING" on my upsert call.
I have created successfully test data and I am adding the id parameter to the page. Any ideas? below code...
Code:
public static testMethod void testUserPage() { User_Request__c u = UserRequest.setupTestReq(); // Construct the standard controller for user request. ApexPages.StandardController s = new ApexPages.standardController(new User_Request__c()); // Switch to runtime context Test.startTest(); // Construct the user req class UserRequest ux = new UserRequest(s); // Call save on the ux PageReference result = ux.save(); // Switch back to test context Test.stopTest(); // Verify the navigation outcome is as expected System.assertEquals(result.getUrl(), s.view().getUrl()); } // Create test user request private static User_Request__c setupTestReq() { Id rid = [select Id from UserRole limit 1].Id; Id pid = [select Id from Profile limit 1].Id; User_Request__c u = new User_Request__c( First_Name__c = 'Dummy', Last_Name__c = 'Test', Role_ID__c = rid, ProfileID__c = pid, User_Name__c = 'dummy@test.com', Title__c = 'Sales', Legacy_User_ID__c = 'dummy', Language__c = 'Finnish', Country__c = 'Finland' ); insert u; system.debug('ID is: '+u.id); PageReference pref = Page.UserRequest; pref.getParameters().put('id',u.id); Test.setCurrentPage(pref); return u; }
I get the error when I call save method in test:
The save method is written in the extension. I was trying to get hint from pdf2Quote wiki example - maybe the issue is there as the example uses only custom controller...