Creating isolated integration tests

Isolated integration tests are automated tests that work with database objects within their own separate database. A new clean database instance is created for each test (using the default Kentico installation scripts) and then deleted after the test run. Note that integration tests are significantly slower than unit tests with faked data.

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.


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.

Creating isolated integration tests

  1. Open the solution containing your test project in Visual Studio.

  2. Make the test class inherit from the IsolatedIntegrationTests base class.

     using CMS.Tests;
     using NUnit.Framework;
     public class MyIntegrationTests : IsolatedIntegrationTests
  3. Write the required isolated integration test methods.

  4. (Optional) Create an app.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 file. If not specified, the test initialization searches the parent directories of the test project and attempts to locate the default Kentico 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

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

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.