Test Harness

The Test Harness allows you to send API requests into the GameSparks platform in their raw form to see the responses that the server returns for any given request:

The Test Harness comes with two key tools for refining and developing your Cloud Code:

FAQs? You can review Frequently Asked Questions about the Test Harness.

Getting to Know the Test Harness

You can open the Test Harness directly from the main left-hand navigation menu in the Portal:

There are several sections in the Test Harness page:

Seeing Debugger! The Debugger is not always in view. If you have selected an Event which has Cloud Code attached to it, the Debugger will automatically appear but only when you run the Event and only if you haven't enabled for Cloud Code Profiling.

Starting a Test Harness Session

When you first access the Test Harness page within the Developer Portal, it will establish a session with the GameSparks platform. At this point the Test Harness is connected to GameSparks but no player is currently authenticated within this session. The initial connection handshaking methods are shown in the Inspector section.

When you have issued one of the available authentication requests (for example, AuthenticationRequest, DeviceAuthenticationRequest, and so on) with valid player details, you will see an Auth Token (authentication token) in the Connection section.

Issuing a Request

To issue a request from the Test Harness, simply enter the JSON for the request into the JSON section and click Send Request:

The Inspector will show the request (in green), and the response (in blue).

Re-Issuing a Request

To re-issue a request, click the rotated arrow in the Inspector window. The request JSON is copied into the JSON section so that you can re-send the request:

Working with Requests

The Requests section contains a selection of buttons which will populate the JSON section with the correctly formatted text for a given request. The requests are grouped by functional area. Click on a functional area to display a submenu of buttons for each request it contains:

Debugger! If you are using LogEventRequest with Cloud Code scripts, then at execution the Debugger may appear.

Example Requests

Example 1

1. Click the Player functional area to display the player-related requests.

2. Click ChangeUserDetailsRequest button and populate the JSON section with the specific request details:

Make any changes to the request that you require, such as removing optional fields or changing the default data values and then click to Send Request.

Example 2

You can also issue several requests at once simply by creating a JSON array of requests in the JSON section. For example, to authenticate a player and then query their details include the two requests in a JSON array such as this.

Note: You'll need outer square brackets and comma separator between each request to build a well-formed JSON array.

Saving Requests as a Scenario

1. To save an individual request as a scenario, first click on the icon in the JSON section.

2. Give your scenario a meaningful name and click the Save button.

The scenario is saved to Scenarios area of the Requests section and can be recalled to the JSON section in the future:

Scenario Limit! A limit of 4000 characters is imposed on the JSON you save under a Scenario.

Recording Multi-Request Scenarios

You can also record a sequence of requests with the Test Harness and then save this multi-request sequence as a scenario.

1. Enter the first request in the JSON section.

2. Click the microphone icon, which will switch to be highlighted to indicate that the Test Harness is now recording subsequent requests.

3. Click to Send Request as normal.

4. Select the next request, in the JSON section enter the request details, and then Send Request:

Record Mode. The microphone icon remains highlighted to show that record-scenario mode is enabled.

5. Repeat these steps for each of the requests you want to include in your scenario.

6. When you've entered and sent all the requests you want in your multi-request scenario, click the highlighted microphone icon a second time to stop recording. The JSON section will be populated with an array of all the requests that you sent whilst recording.

This multi-request scenario can now be saved as described in the previous section.

Scenario Limit! A limit of 4000 characters is imposed on the JSON you save under a Scenario.