> For the complete documentation index, see [llms.txt](https://docs.licensespring.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.licensespring.com/sdks/go-sdk/v2/samples/how-to-run-tests.md).

# How To Run Tests

In addition to the provided samples, there are also **tests** written in the repository. These tests work similarly to the samples but **automatically verify** the correct behavior of the SDK using the **testing** package.

{% stepper %}
{% step %}

### Create a test license

Create a license with product code `test`.

This license must support:

* Online activation
* Consumption
* Borrowing
* Floating cloud
* It must have available floating slots and consumption units
* It must also include a **feature** with:
  * Floating cloud consumption
  * Feature code: `testFeature`
  * Available floating slots and consumption units
    {% endstep %}

{% step %}

### Run the core tests

Once the license above is created, run the following tests:

* `TestLicenseConsumption`
* `TestActivateLicense`
* `TestLicenseFeatureConsumption`
* `TestLicenseCheckAndRelease`
* `TestLicenseFeatureCheckAndRelease`
* `TestLicenseFloatingBorrow`
  {% endstep %}

{% step %}

### Additional test cases

* Create a license with product code `testDisabled`, disable it, then run:
  * `TestActivateDisabledLicense`
* Create an expired license with product code `testExpired`, then run:
  * `TestExpiredLicenseCheck`
    {% endstep %}

{% step %}

### What the tests do

These tests automatically:

* Activate licenses
* Update consumptions
* Check licenses
* Perform releases

They validate that changes are properly reflected both in the **license response** and **local storage**.
{% endstep %}

{% step %}

### Configure config.yaml

To run the tests correctly, you must configure your `config.yaml` file properly by providing the necessary credentials and license details.

{% code title="config.yaml" %}

```yaml
clientId: "your-client-id"
clientSecret: "your-client-secret"
cryptoProviderKey: "your-crypto-provider-key" # Required if using OAuth
apiKey: "your-api-key"
sharedKey: "your-shared-key"
verbose: true
verify_signature: true

products:
  productCode1:
    licenseKey: "your-license-key"
  productCode2:
    username: "your-username"
    password: "your-password"
```

{% endcode %}
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
Important: To run the tests correctly, you must configure your `config.yaml` file properly by providing the necessary credentials and license details (see the `config.yaml` example above).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.licensespring.com/sdks/go-sdk/v2/samples/how-to-run-tests.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
