---
title: Creating isolated integration tests
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

Isolated integration tests are [automated tests](https://docs.kentico.com/13/custom-development/writing-automated-tests.md) that work with database objects within their own separate database. A new clean database instance is created for each test (using the default Xperience installation scripts) and then deleted after the test run. Note that integration tests are significantly slower than [unit tests with faked data](https://docs.kentico.com/13/custom-development/writing-automated-tests/faking-info-and-provider-objects-in-unit-tests.md).

All test classes with isolated integration tests must inherit from the **IsolatedIntegrationTests** base class (provided by the _CMS.Tests_ library). The base class automatically performs database initialization before test runs and cleanup thereafter.

> **Note:** **Requirements**
>
> To use isolated integration tests, you need to have **Microsoft SQL Server 2012 Express LocalDB v11** (or newer) installed. LocalDB is automatically included in Visual Studio or Microsoft SQL Server installations.
>
> <!-- dev-model:core start -->
>
> **ASP.NET Core development model.** Applies only when building with ASP.NET Core. If this page also covers MVC 5, that version is in its own block.
>
> If you wish to run integration tests in environments with no native LocalDB support (e.g., on Linux distributions), see [Running isolated integration tests without LocalDB](#creatingisolatedintegrationtests-linux).
>
> <!-- dev-model:core end -->

## Creating isolated integration tests

1. Open the solution containing your [test project](https://docs.kentico.com/13/custom-development/writing-automated-tests/creating-automated-test-projects.md) in Visual Studio.
2. Make the test class inherit from the **IsolatedIntegrationTests** base class.

   ```csharp

   using CMS.Tests;
   using NUnit.Framework;

   [TestFixture]
   public class MyIntegrationTests : IsolatedIntegrationTests
   {
       ...
   }

   ```
3. Write the required isolated integration test methods.
4. (Optional) Create a **Tests.config** file in your test project and set the following keys under the _configuration/appSettings_ section:

   - **CMSTestDatabaseScriptFolderPath** – the path to the folder with files required for database creation. The folder must contain the _SQL.zip_ file. If not specified, the test initialization searches the parent directories of the test project and attempts to locate the default Xperience installation scripts under the _CMS\App\_Data\Install_ folder path.
   - **CMSTestDatabaseFolderPath** – the path to the folder that will contain test databases. If not specified, the databases are stored in the _TestDatabases_ folder under the current solution's root folder.
   - **CMSTestDatabaseInstanceName** – the name of the SQL server instance used by tests. The default value is: _(localdb)\MSSQLLocalDB_

```xml

<appSettings>
  <add key="CMSTestDatabaseScriptFolderPath" value="C:\inetpub\wwwroot\Xperience\CMS\App_Data\Install" />
  <add key="CMSTestDatabaseFolderPath" value="C:\CustomDBFolder" />
  <add key="CMSTestDatabaseInstanceName" value="(localdb)\CustomTestingInstance" />
</appSettings>

```

Each test in a test class inheriting from **IsolatedIntegrationTests** uses its own database, which is automatically initialized before the test run and cleaned up after.

<!-- dev-model:core start -->

**ASP.NET Core development model.** Applies only when building with ASP.NET Core. If this page also covers MVC 5, that version is in its own block.

## Running isolated integration tests without SQL Express LocalDB or integrated authentication support

By default, Xperience uses a LocalDB instance to automatically manage databases for isolated integration tests via integrated security authentication.

In environments where SQL Express LocalDB or integrated security authentication is not supported or available (such as Linux), you need to set an alternative connection string for the test project via the **CMSTestIsolatedAltConnectionString** application setting. The connection string needs to specify the server instance intended to host test databases together with authentication credentials for a user with full access (able create and manage databases), for example:

```xml title="Tests.config of the isolated tests project"

<configuration>
    <appSettings>
        <add key="CMSTestIsolatedAltConnectionString" value="Data Source=localhost;Initial Catalog=##DBNAME##;Integrated Security=False;User ID=mylogin;Password=mypassword;Connection Timeout=240;" />"
    </appSettings>
</configuration>

```

The connection string must contain the _##DBNAME##_ string in place of the database name. The system dynamically resolves this value at runtime to create (and dispose of) a database for the given test run.

Moreover, the target SQL Server instance must be running on the same machine and have read-write access to the test databases folder specified via the **CMSTestDatabaseFolderPath** application setting.

<!-- dev-model:core end -->
