---
schema_version: "1"
id: 90688fe665c27aa05015b78f108798faa4472f869d57a9b09e4c37f283d3039e
title: Test Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_canvas_Test.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_canvas_Test.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 2501a7731cd1076096230b09c11ceba96471bd5a349251f2b68960babd58cab7
description: Contains methods for automated testing of your Canvas classes.
---
# Test Class

Contains methods for automated testing of your Canvas classes.

## Namespace

[Canvas](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Canvas.htm "The Canvas namespace provides an interface and classes for canvas apps in Salesforce.")

## Usage

Use this class to test your implementation of [Canvas.CanvasLifecycleHandler](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_canvas_CanvasLifecycleHandler.htm "Implement this interface to control context information and add custom behavior during the application render phase.") with mock test data. You can create a test Canvas.RenderContext with mock application and environment context data and use this data to verify that your CanvasLifecycleHandler is being invoked correctly.

- **[Test Constants](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_canvas_Test_constants.htm)**  
    The Test class provides constants that are used as keys when you set mock application and environment context data.
- **[Test Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_canvas_Test_methods.htm)**  
    The Test class provides methods for creating test contexts and invoking your CanvasLifecycleHandler with mock data.

#### See Also

- [_Canvas Developer Guide_: Testing Your CanvasLifecycleHandler Implementation](https://developer.salesforce.com/docs/atlas.en-us.264.0.platform_connect.meta/platform_connect/canvas_testing_your_canvaslifecyclehandler.htm "Canvas Developer Guide: Testing Your
    CanvasLifecycleHandler Implementation - HTML (New Window)")