Book Image

Learning Apex Programming

5 (1)
Book Image

Learning Apex Programming

5 (1)

Overview of this book

Table of Contents (17 chapters)
Learning Apex Programming
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 9. Test Coverage

Ah yes, the Achilles heel of developers as a whole. No one enjoys writing test coverage, or extensively testing their functionality against potential end user pitfalls, but it is nevertheless a real requirement. For the Salesforce1 Platform, it is recommended that the developer strive for 100 percent coverage across every class, but only 75 percent average across all classes is required to actually deploy one's code to Production.

There are two schools of writing test coverage, one that is the half-assed approach of just getting lines covered to get the percentage required, and the other, which is the correct approach, of writing test coverage that mimics the business process, which should by its very progression cause your code to be executed and thereby tested. This also means that your test methods should assert that what you expect to have taken place actually did take place. A developer should never simply assume that because the code has lines covered and it...