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

how to write Test class
pPublic CreateAcc(){
accountID = '';
account = new account();
}
Public void JoinAcc(){
If (accountID.trim()!=''){
list<account> acclist = new list<account>();
acclist = [select id,name,BillingCountry,BillingState,Account_Type__c,Account_ID__c from account where Account_ID__c = :accountID];
account =acclist[0];
}
share your Full class code here..
public class CreateAccount {
public string accountID{get;set;}
public account account{get;set;}
public CreateAcc(){
accountID = '';
account = new account();
}
Public void JoinAcc(){
If (accountID.trim()!=''){
list<account> acclist = new list<account>();
acclist = [select id,name,Account_Type__c,Account_ID__c from account where Account_ID__c = :accountID];
If (acclist.size()>0)
{ account =acclist[0];
}
else
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,'You have provided the wrong account number'));
}
Hi,
go through this code:
@isTest
public class testclassname
{
public static testMethod void testmethodname()
{
Account acc=new Account(name='testaccount',BillingCountry='testcountry',BillingState='teststate',Account_Type__c='testType', Account_ID__c='testid');
insert acc;
yourclassname obj=new yourclassname();
obj.Account_ID__c='testid';
obj.JoinAcc();
}
}
If this solves your problem then please mark it as solution. do not forget to give kudos.
Hi,
Below is your Test class and Apex class.
Apex Class:
Test Class:
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator
My Blog:- http://mrjavascript.blogspot.in/
Thank you