I have a method in the controller
public PageReference add() {
insert technology;
return null;
}
technology is a custom object .It has its own getters and setters.How do I test this method
public static testMethod void testMyController() {
PageReference pageRef = Page.yourPageName;
Test.setCurrentPage(pageRef);
MyController controller = new MyController();
controller.add();
}
In test class You had to initialize Your controler and call this method:
static testMethod void test(){
YourController contr = new YourController();
contr.add();
}
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With