You need to sign in to do that
Don't have an account?
Ishan.Arora
Fetch Apex Message in text Class from Vf page
i want to test a contoller class using Apex Message passed by the controller on the Vf page
But i am not able to get any result as pageMessages comes null
Any ideas how i can do it ?
static testMethod void test_Member(){ //start the test process Test.startTest(); Test.setCurrentPage(Page.BankManagement_Login); TransactionController obj = new TransactionController(); ApexPages.Message[] pageMessages = ApexPages.getMessages(); //List<Apexpages.Message> pageMessages = ApexPages.getMessages(); Boolean check=false; obj.username='aneesh@gmail.com'; obj.password='12'; obj.login(); System.debug('hello1'); for(ApexPages.Message msg:pageMessages){ if (msg.getDetail().contains('Username Or Password is not valid')) { check = true; }else{ check = false; } } system.assert(check); //Stop the test process Test.stopTest(); }
I just shuffle your code slightly. Please try this:
Thanks
Gulshan Raj
All Answers
I just shuffle your code slightly. Please try this:
Thanks
Gulshan Raj