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

@isTest


No, that's not a Twitter handle; this is how a test class is defined as such. This should be the first line of your class, which allows the class to contain test methods and causes the entire class to not be counted against your maximum code storage limit.

Tip

If you are working with an older Salesforce or a Force.com organization, it's possible that you might have classes created prior to API Version 28. Through API Version 27, developers were allowed to place test methods within the class being tested itself. As of Version 28, there must now be a separate class to contain test methods.

The @isTest annotation has a parameter that you can pass in to allow the test method to utilize your organization's existing data:

@isTest (seealldata=true)

In general, this is considered to be bad practice and should only be used if absolutely necessary. Any data you require in order to test your code should be created within the tests themselves. The reason that using real data to fulfill your test...