You need to sign in to do that
Don't have an account?
Nagarjun T
create test class for account detail page class
Hello, Here iam representing my code for this class i have to create @Test class
public class TRN_AccountDetailPage_Ctrl {
//Getter setter //Property
public Account acct{Get;Set;}
//Constructor same sa class name
public TRN_AccountDetailPage_Ctrl(){
string strid = apexpages.currentpage().getparameters().get('id');
if(strid !=''&& strid !=null){
acct =[select id,name,phone,Accountnumber,Billingcity,billingcountry,billingstreet,fax from Account where id=:strid];
}
}
}
public class TRN_AccountDetailPage_Ctrl {
//Getter setter //Property
public Account acct{Get;Set;}
//Constructor same sa class name
public TRN_AccountDetailPage_Ctrl(){
string strid = apexpages.currentpage().getparameters().get('id');
if(strid !=''&& strid !=null){
acct =[select id,name,phone,Accountnumber,Billingcity,billingcountry,billingstreet,fax from Account where id=:strid];
}
}
}
I will recommend you to start using trailhead to learn about test classes
1) https://trailhead.salesforce.com/modules/apex_testing
Pleasse check below post sample test class
1) http://amitsalesforce.blogspot.com/2015/06/best-practice-for-test-classes-sample.html
Also please check below post
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_qs_test.htm
2) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_example.htm
You write a test class for this the same way that you would any other:
- Set up some data for the controller to access (Account, Contact etc)
- Execute a method/methods:-
- Verify the behaviour with asserts.
You Sample test class should be like below Let us know if this will help you
All Answers
Check this code and follow this link as well.
If it is working fine, plz mark it as your ans for other person refernces.
https://developer.salesforce.com/forums/?id=9060G000000Bj8MQAS (http://If it is working fine, plz mark it as your ans for other person refernces. https://developer.salesforce.com/forums/?id=9060G000000Bj8MQAS)
I will recommend you to start using trailhead to learn about test classes
1) https://trailhead.salesforce.com/modules/apex_testing
Pleasse check below post sample test class
1) http://amitsalesforce.blogspot.com/2015/06/best-practice-for-test-classes-sample.html
Also please check below post
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_qs_test.htm
2) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_example.htm
You write a test class for this the same way that you would any other:
- Set up some data for the controller to access (Account, Contact etc)
- Execute a method/methods:-
- Verify the behaviour with asserts.
You Sample test class should be like below Let us know if this will help you