how to set a date in the test class, Thanks in advance.
visual force page:
<apex:page controller=IntegrationController" docType="html-5.0">
<apex:outputPanel >
<div style="font-size:12px; font-weight:bold;">
select Date: <apex:input type="date" value="{!dt}"/>
</div>
</apex:outputPanel>
<apex:commandButton value="Get Data" action="{!getData}" />
</apex:page>
controller:
public class IntegrationController{
public Date dt {get;set;}
public void getData(){
system.debug('in controller ---> '+dt);
String dat = dt.year() + '/' + dt.month() + '/' + dt.day();}
test class:
@isTest
public class IntegrationController_Test {
static testmethod void test1(){
Date testDate =Date.newInstance(2020, 10, 28);
system.debug('in test class: '+testDate );
Test.startTest();
IntegrationController Data = new IntegrationController();
Data.getData();
Test.stopTest();
}
After running the test class I am getting a null value in controller date. Please help me with this issue.
14:16:47:001 USER_DEBUG [8]|DEBUG|in test class: 2020-10-28 00:00:00
14:16:47:065 USER_DEBUG [22]|DEBUG|in controller ---> null