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

test class for simple save
Guys, i am trying to write a test class for a simple save method.
This might be simple, but i cannot get this correct!!!
Apex Class -
public with sharing class ExtUpdated {
ApexPages.StandardController stdcontroller ;
public ExtUpdated(ApexPages.StandardController controller) {
stdcontroller = controller; }
public PageReference todo(){
stdcontroller.save();
return (new pagereference('/apex/confirm').setredirect(true));}}
Test Class -
@isTest
public class TestExtUpdated {
static testMethod void saveNewCase() {
Case co = new Case();
insert co;
Test.startTest();
PageReference pageRef = Page.MyVFPage; // Add your VF page Name here
Test.setCurrentPage(pageRef);
ApexPages.StandardController sc = new ApexPages.StandardController(co);
sc.save();
Test.stopTest();
}}
No errors, but the test coverage is 0%.
Thanks for your help!!!
This might be simple, but i cannot get this correct!!!
Apex Class -
public with sharing class ExtUpdated {
ApexPages.StandardController stdcontroller ;
public ExtUpdated(ApexPages.StandardController controller) {
stdcontroller = controller; }
public PageReference todo(){
stdcontroller.save();
return (new pagereference('/apex/confirm').setredirect(true));}}
Test Class -
@isTest
public class TestExtUpdated {
static testMethod void saveNewCase() {
Case co = new Case();
insert co;
Test.startTest();
PageReference pageRef = Page.MyVFPage; // Add your VF page Name here
Test.setCurrentPage(pageRef);
ApexPages.StandardController sc = new ApexPages.StandardController(co);
sc.save();
Test.stopTest();
}}
No errors, but the test coverage is 0%.
Thanks for your help!!!
You need to instantaniate and call todo method of your class from test class,
Hope this help
--
Thanks
Swayam
@salesforceguy
All Answers
You need to instantaniate and call todo method of your class from test class,
Hope this help
--
Thanks
Swayam
@salesforceguy
Thanks for your response, but the coverage still shows 0%.