# Testing
source: https://developer.mastercard.com/merchant-self-services/documentation/testing/index.md

Use the resources in this section to validate your Merchant Self Services integration in the Sandbox environment. Start with the prerequisites and authentication guidance, then follow the test path for Consumer Clarity or Ethoca Alerts for Merchants.

## Before You Begin {#before-you-begin}

Before running the test cases in this section:

1. Complete the steps in the [Quick Start Guide](https://developer.mastercard.com/merchant-self-services/documentation/tutorials-and-guides/quick-start-guide/index.md).

2. Verify your Sandbox credentials and OAuth configuration.

3. Successfully complete the first Sandbox API call as described in the Quick Start Guide.

For project setup and credential instructions, see the [Quick Start Guide](https://developer.mastercard.com/merchant-self-services/documentation/tutorials-and-guides/quick-start-guide/index.md). For a complete Java implementation of OAuth signing and an API request, see the [Reference Application Tutorial](https://developer.mastercard.com/merchant-self-services/documentation/tutorials-and-guides/reference-app-tutorial/index.md).

## Choose an authentication and testing route {#choose-an-authentication-and-testing-route}

All Merchant Self Services Sandbox requests require OAuth 1.0a authentication. Choose the route that matches how you want to run your tests:

* **Postman:** Use the [Postman Collection](https://developer.mastercard.com/merchant-self-services/documentation/postman-collection/index.md) to configure credentials and send requests without writing an API client.

* **Generated Java client:** Use the [Reference Application Tutorial](https://developer.mastercard.com/merchant-self-services/documentation/tutorials-and-guides/reference-app-tutorial/index.md) to generate a client from the OpenAPI Specification and run a complete Java example.

* **Command line:** Use the first Sandbox cURL request in the [Quick Start Guide](https://developer.mastercard.com/merchant-self-services/documentation/tutorials-and-guides/quick-start-guide/index.md#make-your-first-sandbox-api-call) to verify authentication and connectivity before testing additional operations.

## Recommended testing workflow {#recommended-testing-workflow}

Follow these steps so that authentication and reusable resource identifiers are validated before dependent operations are tested.

1. **Verify Sandbox authentication and connectivity.** Run the first Sandbox request in the [Quick Start Guide](https://developer.mastercard.com/merchant-self-services/documentation/tutorials-and-guides/quick-start-guide/index.md#make-your-first-sandbox-api-call).

2. **Confirm the initial response.** Verify that the API returns HTTP `200 OK` and a response body that matches the documented schema.

3. **Choose a product test path.**

   * Use the [Clarity Test Cases](https://developer.mastercard.com/merchant-self-services/documentation/testing/clarity-test-cases/index.md) to test Merchant Self Services operations for Consumer Clarity.

   * Use the [Alerts Test Cases](https://developer.mastercard.com/merchant-self-services/documentation/testing/alerts-test-cases/index.md) to test Merchant Self Services operations for Ethoca Alerts for Merchants.

4. **Run create operations before dependent operations.** When a test creates a resource, save the identifier returned in the response for later retrieve, update, or delete requests.

5. **Run retrieve operations.** Retrieve the resource and compare the response with the values submitted in the create request.

6. **Run update operations.** When an operation requires an `If-Match` header, use the latest `Etag` value returned for that resource.

7. **Complete cleanup steps.** Run the applicable delete or deactivation test when the test case provides one.

## Validation checks {#validation-checks}

For each request, verify the following:

* The request uses the Sandbox base URL.
* The OAuth 1.0a signature is generated for the exact HTTP method and request URL being sent.
* All required headers, path parameters, query parameters, and request-body fields are present.
* The HTTP status code matches the successful response documented for the operation.
* The response body matches the documented schema, when the successful response includes a body.
* Resource identifiers returned by create operations are saved and used in dependent requests.
* The values returned by retrieve operations match the test data submitted earlier in the workflow.
* The latest `Etag` response-header value is used when an update operation requires `If-Match`.

<br />

Use the [API Reference](https://developer.mastercard.com/merchant-self-services/documentation/api-reference/index.md) to confirm each operation's required inputs, successful status code, response schema, and headers.

## Troubleshooting {#troubleshooting}

Use the following guidance if a request does not return the expected result:

* **Authentication or signature failure:** Verify the consumer key, private signing key, OAuth 1.0a signature, HTTP method, and complete request URL. Review the [Quick Start Guide](https://developer.mastercard.com/merchant-self-services/documentation/tutorials-and-guides/quick-start-guide/index.md) and [Reference Application Tutorial](https://developer.mastercard.com/merchant-self-services/documentation/tutorials-and-guides/reference-app-tutorial/index.md).

* **`400 Bad Request`:** Check for missing required headers, malformed JSON, invalid field values, or an unsupported parameter combination. Compare the request with the [API Reference](https://developer.mastercard.com/merchant-self-services/documentation/api-reference/index.md).

* **Other error codes returned:** Review [Code and Formats](https://developer.mastercard.com/merchant-self-services/documentation/code-and-formats/index.md) for detailed information about error response handling for the Merchant Self Services API.

* **Issue remains unresolved:** Review [API Basics](https://developer.mastercard.com/merchant-self-services/documentation/api-basics/index.md). Then, if necessary, contact the [Ethoca Customer Delivery Team](mailto:customerdelivery@ethoca.com) or use [Mastercard Developer Support](https://developer.mastercard.com/support/).

## Test-case resources {#test-case-resources}

* [Clarity Test Cases](https://developer.mastercard.com/merchant-self-services/documentation/testing/clarity-test-cases/index.md) show different ways to use the Merchant Self Services API for Consumer Clarity.
* [Alerts Test Cases](https://developer.mastercard.com/merchant-self-services/documentation/testing/alerts-test-cases/index.md) show how to use the Merchant Self Services API for Ethoca Alerts for Merchants.
