You need to sign in to do that
Don't have an account?
Meenakshi sinha
Hello
Pls guide me in writing test class for the VF page.
<apex:page standardController="Account"
recordSetVar="accounts"
tabStyle="Account"
sidebar="false">
<apex:pageBlock title="">
<apex:repeat value="{!accounts}" var="a">
<apex:pageBlockSection title="{!a.Name}"/>
<apex:relatedList list="Contacts"
subject="{!a.ID}"
id="relatedlist1"
title="Contact Info"/>
<apex:relatedList list="Opportunities"
subject="{!a.ID}"
id="relatedlist2"
title="Opportunity Info"/>
</apex:repeat>
</apex:pageBlock>
</apex:page>
@istest(SeeAllData=False)
private class MyCls_Test
{
private static testmethod void testdata()
{
Profile p=[Select Id from profile where name ='System Administrator'];
User u=new User(ProfileId = p.Id, username = 'testmail@org.com', email = 'testuser@gmail.com',
EmailEncodingKey = 'UTF-8' , LocaleSidKey = 'en_US',
LanguageLocaleKey = 'en_US', timezonesidkey = 'America/Los_Angeles',
alias='cspu', lastname='lastname');
System.RunAs(u)
{
}
}
Thanks
meenakshi
how to write test class
Hello
Pls guide me in writing test class for the VF page.
<apex:page standardController="Account"
recordSetVar="accounts"
tabStyle="Account"
sidebar="false">
<apex:pageBlock title="">
<apex:repeat value="{!accounts}" var="a">
<apex:pageBlockSection title="{!a.Name}"/>
<apex:relatedList list="Contacts"
subject="{!a.ID}"
id="relatedlist1"
title="Contact Info"/>
<apex:relatedList list="Opportunities"
subject="{!a.ID}"
id="relatedlist2"
title="Opportunity Info"/>
</apex:repeat>
</apex:pageBlock>
</apex:page>
@istest(SeeAllData=False)
private class MyCls_Test
{
private static testmethod void testdata()
{
Profile p=[Select Id from profile where name ='System Administrator'];
User u=new User(ProfileId = p.Id, username = 'testmail@org.com', email = 'testuser@gmail.com',
EmailEncodingKey = 'UTF-8' , LocaleSidKey = 'en_US',
LanguageLocaleKey = 'en_US', timezonesidkey = 'America/Los_Angeles',
alias='cspu', lastname='lastname');
System.RunAs(u)
{
}
}
Thanks
meenakshi
You dnt need to write any test class for above VF page because above VF nt contain any apex class. We need to write test class for apex class and trigger only.
Please let us know if this will help u
Thanks
Amit Chaudhary
All Answers
You dnt need to write any test class for above VF page because above VF nt contain any apex class. We need to write test class for apex class and trigger only.
Please let us know if this will help u
Thanks
Amit Chaudhary