Questions related to the design and development or any other area of unit tests should be tagged with the unit-test tag.
Unit tests typically require setting up data on which the code under test operates. As of API version 24 (Spring '12) unit test methods do not have access to the organization's data by default, with the exception of setup and metadata objects. However, the organization's data can still be accessed by explicitly indicating that intent by using the @isTest(SeeAllData=true) annotation.
Once the data is set up the unit of code under test is executed and then typically System.assert assertions about the results of the execution are made.
To learn more about unit tests in Salesforce see the following.
- Introduction to Apex test methods
- Apex unit testing
- Running unit tests
- @isTest annotation
- Isolation of test data from organization data in unit tests
- How to write good unit tests
Attribution to: Peter Knolle
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/697