Showing posts with label Apex. Show all posts
Showing posts with label Apex. Show all posts

Sunday, 10 April 2016

GET READY FOR CHANGES TO APEX TESTING - Spring'16 Release



The Salesforce Spring'16 released with a long list of changes. As a developer, the changes that most excite me are generally those that are covered in the Development and Deployment categories of the Salesforce release notes.


Test Suites for Apex Test Classes


Salesforce has now added the option Suite to group unit test classes into test suites.you have test classes which you run every time while you preparing for deployment. Now, with this new feature, you can create test suite which contains those set of classes. Also, you can create or modify test suites that contain up to 200 test classes using the Developer console.

To create a Test Suite using Developer console : Select Test | New Suite.




Enter a name for your Test Suite.



To choose which classes are in a test suite, select Test | Suite Manager | Your Test Suite | Edit Suite.



Once you select your test classes(it will we more than one also), click on save button. After this to run your test class which you have selected, click on Test | New Suite Run.



Select the Test Suite you want to run and then click on your right corner button "Run Suite".



After clicking on Run Suite, you can see you result here:


Now you have created the test suite and executed your test classes. Isn't that easy..!!


Set and Modify CreatedDate field of the Tests Records


There is a new method has been introduced System.Test.setCreatedDate. You can change your records created date in the test class. This method we can utilize to test the scenarios where we are using created dates of a record.

Here is the example of how to use this method.


1:  Account a = new Account(name='myAccount');  
2:  insert a;  
3:  Test.setCreatedDate(a.Id, DateTime.newInstance(2012,12,12));  


Wednesday, 13 January 2016

VisualForce Basics



  • It is a mark-up language same as html.
  • It will be easier for the salesforce developers once they know how to combine the VisualForce  page with Apex.
  • It is much easier to learn compare to Apex.


MVC Pattern in Visualforce Page

The Model is simply the underlying database. In Visualforce, it’s the collection of Salesforce objects and fields that we had represent and modify in our page.

The View is the code that makes up our page’s UI. Here, it’s all of our Visualforce, HTML, CSS, and JavaScript code.

The Controller is the middle layer between the model and the view. It’s the Apex code that interacts with the database according to the view’s needs.



Where to write Visualforce Code?

For writing your first code in Visualforce Page, you need to start from here:

Step 1: Turn Development mode on in your user detail page.
             Your Name >> My Settings >> Personal >> Advanced User Details



Check both boxes and save it. This enables a VisualForce editor whenever you view your VisualForce page.

Step 2: Create a new VisualForce page
             Setup >> Develop >> Pages >> New 



Step 3: Click the New button and started writing your VisualForce code.




Step 4: Click the Preview button to open up the Visualforce editor.
    


Visualforce Tags

Here are the VisualForce tags that are used commonly in our visualforce development. We will discuss all the visualforce tags in my next blog.

<apex:page>
<apex:form>
<apex:pageblock>
<apex:pageBlockSection>

<apex:commandButton>

<apex:pageBlockButtons>

<apex:commandLink>

<apex:outputLink>

<apex:inputField>

<apex:inputFile>

<apex:inputHidden>

<apex:inputsecret>

<apex:inputText>

<apex:inputTextarea>

<apex:inputCheckbox>

<apex:outputField>

<apex:outputLabel>

<apex:outputText>

<apex:pageBlockSectionItem>

<apex:pageBlockTable>

<apex:column>

<apex:dataTable>

<apex:tabPanel>

<apex:tab>

<apex:toolbar>

<apex:toolbarGroup>

<apex:pageMessage>

<apex:panelBar>

<apex:panelBarItem>

<apex:panelGrid>

<apex:panelGroup>

<apex:param>

<apex:repeat>

<apex:facet>

<apex:actionFunction>

<apex:detail>

<apex:actionPoller>

<apex:actionRegion>

<apex:variable>

<apex:stylesheet>

<apex:SectionHeader >

<apex:relatedList>

<apex:listViews>

<apex:enhancedList>

<apex:actionStatus>

<apex:actionSupport>



Hope this helps you.  Happy Coding :)