Apex Test Coverage Best Practices - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Apex Test Coverage Best Practices

Description:

Further information on these and other factors that could affect our financial ... Critical component of the development process. Test Driven Development ... – PowerPoint PPT presentation

Number of Views:421
Avg rating:3.0/5.0
Slides: 18
Provided by: bodi52
Category:

less

Transcript and Presenter's Notes

Title: Apex Test Coverage Best Practices


1
Apex Test Coverage Best Practices
Track Tour de Force Mastering the Force.com
Platform
  • Taggart Matthiesen, salesforce.com

2
Safe Harbor Statement
Safe harbor statement under the Private
Securities Litigation Reform Act of 1995 This
presentation may contain forward-looking
statements including but not limited to
statements concerning the potential market for
our existing service offerings and future
offerings. All of our forward looking statements
involve risks, uncertainties and assumptions. If
any such risks or uncertainties materialize or if
any of the assumptions proves incorrect, our
results could differ materially from the results
expressed or implied by the forward-looking
statements we make. The risks and uncertainties
referred to above include - but are not limited
to - risks associated with possible fluctuations
in our operating results and cash flows, rate of
growth and anticipated revenue run rate, errors,
interruptions or delays in our service or our Web
hosting, our new business model, our history of
operating losses, the possibility that we will
not remain profitable, breach of our security
measures, the emerging market in which we
operate, our relatively limited operating
history, our ability to hire, retain and motivate
our employees and manage our growth, competition,
our ability to continue to release and gain
customer acceptance of new and improved versions
of our service, customer and partner acceptance
of the AppExchange, successful customer
deployment and utilization of our services,
unanticipated changes in our effective tax rate,
fluctuations in the number of shares outstanding,
the price of such shares, foreign currency
exchange rates and interest rates. Further
information on these and other factors that could
affect our financial results is included in the
reports on Forms 10-K, 10-Q and 8-K and in other
filings we make with the Securities and Exchange
Commission from time to time. These documents are
available on the SEC Filings section of the
Investor Information section of our website at
www.salesforce.com/investor. Salesforce.com, inc.
assumes no obligation and does not intend to
update these forward-looking statements, except
as required by law.
3
Taggart Matthiesen Senior Product Manager, Apex
Code
4
Agenda
  • Development and Testing
  • Apex Test Framework
  • Testing Scenarios and Examples
  • Testing Roadmap
  • QA

5
Development and Testing
  • Testing the afterthought
  • Completed after development
  • Not enough coverage
  • No automation

6
Development and Testing
  • Testing the afterthought
  • Completed after development
  • Sacrificed to keep timeline
  • Not enough coverage
  • Not all scenarios are evaluated
  • No automation
  • New requirements, manual testing, new resources

7
Development and Testing
There is hope
8
Benefits of Testing
  • Testing the key to successful long term
    development
  • Critical component of the development process
  • Test Driven Development
  • Behavioral validation (positive and negative)
  • Validate all logical paths
  • Automation, automation, automation
  • Test suites / catch regressions
  • Supports future changes and extensions
  • Provides support for R1, R2, R3, R3b, etc

9
Test-Driven Development
Continuous Innovation 27 Major Releases in 9
YearsOn Average Over 100 New Features Per Release
10
Apex Test Framework
You shall not PASS!
11
Apex Test Framework
public class HelloDevs public static String
getGreeting() return (Test Away!) static
testmethod void testGreeting() String gr
HelloDevs.getGreeting() System.assertEquals(Test
Away!,gr)
  • Apex Test Methods
  • static testmethod void testGreeting()
  • _at_isTest
  • Behavioral Assertions
  • System.assertEquals(Test Away!, gr)
  • Try/Catch assertions (eg dml exceptions)
  • System.runAs(user u)
  • Test Setup
  • Test.startTest() and Test.stopTest()
  • Validate bulk operations

12
Apex Test Framework
public class HelloDevs public static String
getGreeting() return (Test Away!) static
testmethod void testGreeting() String gr
HelloDevs.getGreeting() System.assertEquals(Test
Away!,gr)
  • Code Coverage Statistics
  • Number of tests run, test failures
  • Code coverage and profiling

13
Apex Test Framework
  • Mileage Tracker Application
  • Requirements
  • Track daily mileage for employees
  • Limit mileage to 500 miles per day
  • Design Components
  • Mileage Custom object
  • Mileage Trigger
  • Mileage Utility Class

14
Apex Test Framework Roadmap
  • System.runAs() include CRUD and FLS validation
  • Callout Support
  • Apex Debugger

15
Manage. Share. Build. Apply what youve learned
  • Testing is Development
  • Strive for 100 code coverage
  • Test negative and positive behavior (use cases)
  • Build your test dataset
  • Validate against bulk operations

16
Session FeedbackLet us know how were doing and
enter to win an iPod nano!
  • Please score the session from 5 to 1
    (5excellent,1needs improvement) in the
    following categories
  • Overall rating of the session
  • Quality of content
  • Strength of presentation delivery
  • Relevance of the session to your organization

Additionally, please fill in the name of each
speaker score them on overall delivery.
We strive to improve, thank you for filling out
our survey.
17
QUESTION ANSWER SESSION
Write a Comment
User Comments (0)
About PowerShow.com