---
schema_version: "1"
id: 31fda0c57cfe345f6937ecb4fa9db481e1dbacda37642ca2e1cf6985220f6bac
title: mockRenderContext(applicationContextTestValues, environmentContextTestValues)
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_canvas_Test_mockRenderContext.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_canvas_Test_mockRenderContext.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 53f490ee762750538f615b7b3d6b1e9bf7dcd64ff2df3f75ade54a69d1671b0b
description: Creates and returns a test Canvas.RenderContext based on the provided application and environment context parameters.
---
# mockRenderContext(applicationContextTestValues, environmentContextTestValues)

Creates and returns a test Canvas.RenderContext based on the provided application and environment context parameters.

## Signature

public static Canvas.RenderContext mockRenderContext(Map<String,String\> applicationContextTestValues, Map<String,String\> environmentContextTestValues)

## Parameters

- **applicationContextTestValues**:
    
    Type: [Map](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_map.htm#apex_methods_system_map "Contains methods for the Map collection type.")<[String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type."),String>
    
    Specifies a map of key-value pairs that provide mock application context data. Use [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.") that are provided by Canvas.Test as keys. If null is provided for this parameter, the canvas framework generates some default mock application context values.
- **environmentContextTestValues**:
    
    Type: [Map](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_map.htm#apex_methods_system_map "Contains methods for the Map collection type.")<[String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type."),String>
    
    Specifies a map of key-value pairs that provide mock environment context data. Use [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.") provided by Canvas.Test as keys. If null is provided for this parameter, the canvas framework generates some default mock environment context values.

## Return Value

Type: [Canvas.RenderContext](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_canvas_RenderContext.htm "A wrapper interface that is used to retrieve application and environment context information.")

## Usage

Use this method to create a mock Canvas.RenderContext. Use the returned RenderContext in calls to [Canvas.Test.testCanvasLifecycle(lifecycleHandler, mockRenderContext)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_canvas_Test_testCanvasLifecycle.htm "Calls the Canvas test framework to invoke a CanvasLifecycleHandler with the provided RenderContext.") for testing Canvas.CanvasLifecycleHandler implementations.

## Example

The following example creates maps to represent mock application and environment context data and generates a test Canvas.RenderContext. This test RenderContext can be used in a call to [Canvas.Test.testCanvasLifecycle(lifecycleHandler, mockRenderContext)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_canvas_Test_testCanvasLifecycle.htm "Calls the Canvas test framework to invoke a CanvasLifecycleHandler with the provided RenderContext.").

Map<String,String\> appValues = new Map<String,String\>();
appValues.put(Canvas.Test.KEY\_NAMESPACE,'alternateNamespace');
appValues.put(Canvas.Test.KEY\_VERSION,'3.0');

Map<String,String\> envValues = new Map<String,String\>();
envValues.put(Canvas.Test.KEY\_DISPLAY\_LOCATION,'Chatter');
envValues.put(Canvas.Test.KEY\_LOCATION\_URL,'https://MyDomainName.my.salesforce.com/\_ui/core/chatter/ui/ChatterPage');//MyDomainName is a placeholder value

Canvas.RenderContext mock = Canvas.Test.mockRenderContext(appValues,envValues);

#### 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)")