You need to sign in to do that
Don't have an account?
How to Create a Controller
I am a beginner programming.
I was able to create a controller Visualforce, I have trouble knowing how to create a test.
Will you advise how can I create a test look like?
---Visualforce---
<apex:page showHeader="true" title="入力画面" standardController="nyuuryoku__c" extensions="otamesi">
<apex:sectionHeader />
<apex:form >
<apex:pageBlock title="値引き商品情報" >
<apex:pageBlockButtons >
<apex:commandButton value="2.値引き商品計算" action="{!quicksave}" />
</apex:pageBlockButtons>
<table class="otamesi1table" border="3" style="float:left" width="700" >
<tr>
<th bgcolor="#9999ff" height="20"></th>
<th bgcolor="#9999ff" height="20">商品名</th>
<th bgcolor="#9999ff" height="20">商品金額</th>
<th bgcolor="#9999ff" height="20">注文台数</th>
<th bgcolor="#9999ff" height="20">小計</th>
</tr>
<tr>
<th height="20">値引き商品1</th>
<td height="20"><apex:outputField value="{!nyuuryoku__c.nebiki1_name__c}"/></td>
<td height="20"><apex:outputField value="{!nyuuryoku__c.nebiki1_nedan__c}"/></td>
<td height="20"><apex:inputField value="{!nyuuryoku__c.nebiki1_daisu__c}"/></td>
<td rowspan="5" align="center" height="20"><apex:inputField value="{!nyuuryoku__c.nebiki_syoukei__c}"/></td>
</tr>
</table>
</apex:pageBlock>
</apex:form>
<apex:form >
<apex:pageBlock title="納品情報" mode="edit" id="up">
<apex:pageBlockButtons >
<apex:commandButton value="3.支払い情報へ" action="{!siharaisave}" reRender="up,down"/>
</apex:pageBlockButtons>
<table class="otamesitable2" border="3" style="float:left" wideth="60%" id="down">
<tr>
<th bgcolor="#9999ff" colspan="2" height="20">書類発送日</th>
<th bgcolor="#9999ff" colspan="2" height="20">保証書発送先</th>
<th bgcolor="#9999ff" colspan="3" height="20">その他の場合</th>
</tr>
<tr>
<td rowspan="3" colspan="2" height="20"><apex:inputField value="{!nyuuryoku__c.syorui_hassou_date__c}"/></td>
<td rowspan="3" colspan="2" height="20"><apex:inputField value="{!nyuuryoku__c.hassousaki__c}"/></td>
<th height="20">名称</th>
<td colspan="2" height="20"><apex:inputField value="{!nyuuryoku__c.hassousaki_name__c}"/></td>
</tr>
<tr>
<th height="20">住所</th>
<td colspan="2" height="20"><apex:inputField value="{!nyuuryoku__c.hassousaki_addr__c}"/></td>
</tr>
<tr>
<th height="20">電話番号</th>
<td colspan="2" height="20"><apex:inputField value="{!nyuuryoku__c.hassousaki_tel__c}"/></td>
</tr>
</table>
</apex:pageBlock>
</apex:form>
<apex:form >
<apex:pageBlock title="支払い情報">
<apex:pageBlockButtons >
<apex:commandButton value="4.確認ページへ" action="{!save}" />
</apex:pageBlockButtons>
<table class="otamesitable3" border="3" style="float:left" width="700">
<tr>
<th bgcolor="#9999ff" height="20">支払い回数</th>
<th bgcolor="#9999ff" height="20">支払い方法</th>
<th bgcolor="#9999ff" height="20">支払期日</th>
<th bgcolor="#9999ff" height="20">支払額</th>
</tr>
<tr>
<th height="20">1回</th>
<td height="20"><apex:inputField value="{!nyuuryoku__c.X1__c}"/></td>
<td height="20"><apex:inputField value="{!nyuuryoku__c.siharaikijitu1__c}"/></td>
<td height="20"><apex:inputField value="{!nyuuryoku__c.siharai1__c}"/></td>
</tr>
</table>
</apex:pageBlock>
</apex:form>
</apex:page>
---Controller---
public class otamesi{
nyuuryoku__c nyu;
private ApexPages.StandardController con;
public otamesi(ApexPages.StandardController stdController){
this.nyu =(nyuuryoku__c)stdController.getRecord();
con = stdController;
}
public void siharaisave(){
nyu =(nyuuryoku__c)con.getRecord();
nyu.Flg1__c = true;
con.save();
}
public PageReference save(){
nyu =(nyuuryoku__c)con.getRecord();
nyu.Flg2__c = true;
return con.save();
}
}
Have you checked these pages on writing unit tests?
http://wiki.developerforce.com/page/How_to_Write_Good_Unit_Tests
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_error_handling.htm
All Answers
Have you checked these pages on writing unit tests?
http://wiki.developerforce.com/page/How_to_Write_Good_Unit_Tests
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_error_handling.htm
Thank you.
Let's take a look in the references.
Also, thank you to know there.