Load TestData Using Static Resource CSV file in Test Class
@isTest
static testMethod void static_testResource(){
List<sobject> cand=Test.loadData(Account.sObjectType,'testAccount');
}
<apex:page controller="SummaryStatsController" readOnly="true"> <p>Here is a statistic: {!veryLargeSummaryStat}</p> </apex:page>
public class SummaryStatsController { public Integer getVeryLargeSummaryStat() { Integer closedOpportunityStats = [SELECT COUNT() FROM Opportunity WHERE Opportunity.IsClosed = true]; return closedOpportunityStats; } }
public class MerchandiseController { public List<Merchandise__c> getAllMerchandise() { List<Merchandise__c> theMerchandise = [SELECT Name, Price__c FROM Merchandise__c LIMIT 10000]; return(theMerchandise); } }
<apex:page controller="MerchandiseController" readOnly="true"> <p>Here is all the merchandise we have:</p> <apex:dataTable value="{!AllMerchandise}" var="product"> <apex:column> <apex:facet name="header">Product</apex:facet> <apex:outputText value="{!product.Name}" /> </apex:column> <apex:column> <apex:facet name="header">Price</apex:facet> <apex:outputText value="{!product.Price__c}" /> </apex:column> </apex:dataTable> </apex:page>