Your SlideShare is downloading. ×
0
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Df12 Top Testing Tips
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Df12 Top Testing Tips

943

Published on

Slides from the Dreamforce 2012 session "Top Testing Tips: Data Creation, Web Callouts, and Automation" …

Slides from the Dreamforce 2012 session "Top Testing Tips: Data Creation, Web Callouts, and Automation"
Description: Take your Apex code testing to the next level with sample code and open source libraries that make these advanced topics easy. Save time with SmartFactory, which automatically creates complex test data for tests isolated from your regular data. Learn how to test web callouts cleanly and completely using interfaces and mocks. Finally, make sure all your team's tests run regularly with native Force.com automation that takes a fraction of the time of full continuous integration.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
943
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Top Testing TipsData Creation, Web Callouts, and AutomationAmi Assayag, CRM Science, @AmiAssayagWes Nolte, Tquila, @WesNolte
  • 2. Safe harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-Q for the most recent fiscal quarter ended July 31, 2012. This documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward- looking statements.
  • 3. Ami AssayagPrincipal Architect, CRM SciencePhillyForce Leader@AmiAssayag
  • 4. Wes NolteDirector of Innovation, TquilaForce.com MVPLondon Dev Group Leader@WesNolte
  • 5. Couldn’t make it…  Matthew Botos Model Metrics a salesforce.com company @BotosCloud
  • 6. Our agenda for today• Review our assigned project• Review top testing tips: • Data creation with SmartFactory • Testing web callouts with interfaces • Automated testing and continuous integration
  • 7. Our assigned projectYouve just been hired as a developer on an existing project and given this story to implement: As a conference attendee, I want to create a Registration for a Session, and post it to my Twitter account.
  • 8. Data Model
  • 9. Business logic is completed!
  • 10. And now we test• Unit testing• Integration testing Acceptance• Automated testing Integration Unit
  • 11. Data creation withSmartFactory
  • 12. Let’s Make a Registration System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Session__c, Contact__c]: [Session__c, Contact__c]
  • 13. Oops, Let’s Make a Session System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Start_Date_Time__c]: [Start_Date_Time__c]
  • 14. Continue creating test data • Identify all objects and related objects • Identify all required fields • Identify valid values for all required fields • Populate all required fields • Rinse & repeat • OR...
  • 15. SmartFactory for Force.com • Apex project • Create test objects • Autofill fields & lookups Custom Contact Account Object
  • 16. Let’s Try SmartFactory
  • 17. SmartFactory for Force.com • Several utility methods • Looking at metadata • bit.ly/SmartFactory
  • 18. Testing web callouts withinterfaces
  • 19. Post to Twitter Architecture Business Logic Callout Utility Trigger Class Class
  • 20. Integration Test
  • 21. Post to Twitter Architecture (w/ an interface) Business Logic Callout Utility Trigger Class Class Mock Implementation Class Interface Production Implementation Class
  • 22. It all starts with an Interface… • Only contains method signatures. • Implemented by other classes. • Implement by providing code for interface methods.
  • 23. Improve the callout class w/ the interface Suddenly our application logic is looking much cleaner.
  • 24. Implementation Class #1: Mock • Similar code to what we removed from the callout utility
  • 25. Implementation Class #2: Production • Performs actual callout.
  • 26. Post to Twitter Architecture (w/ an interface) Business Logic Callout Utility Trigger Class Class Mock Implementation Class Interface Production Implementation Class
  • 27. Using The Interface: Test Method
  • 28. Using The Interface: Business Logic • Treat the interface the same here!
  • 29. Using interfaces in apex testing• Summary of advantages • Tried and tested through Java, .Net and others • Interfaces decouple code and provide consistency • Fewer hacks to get tests to work correctly • Improved code coverage • Can test multiple callout situations with different “dummy” data • bit.ly/ApexCalloutTest
  • 30. Automated testing andcontinuous integration
  • 31. Automated testing and continuous integration • Tests are only run on deployment or explicitly in UI • New production or test code might introduce bugs • Bugs multiplied in complex team dev scenarios Early detection of bug requires that you manually “Run All” tests or implement full-blown CI… or does it?
  • 32. Automated Testing for Force.com (App) • Free App that installs as a managed package with just a few clicks • Runs 100% on the Force.com Platform
  • 33. Super Easy to Set Up
  • 34. Test Results in Your Inbox
  • 35. Open Source• bit.ly/ForceAutoTest• Pull requests are welcomed
  • 36. Ami Assayag Wes NoltePrincipal Architect Director of Innovation CRM Science Tquila @AmiAssayag @WesNolte

×