Test Guide for Microsoft.Data.SqlClient

June 8, 2026 ยท View on GitHub

This guide describes how to run the test projects in this repository and how to configure the SQL Server-backed manual tests.

For build prerequisites and general build.proj usage, see BUILDGUIDE.md.

Test Projects

The primary test projects for Microsoft.Data.SqlClient are under src/Microsoft.Data.SqlClient/tests:

ProjectPathPurpose
Unit testssrc/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft.Data.SqlClient.UnitTests.csprojUnit tests and tests against simulated servers.
Functional testssrc/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.FunctionalTests.csprojFunctional tests for public and internal behavior. Some tests use simulated servers or local test infrastructure.
Manual testssrc/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTests.csprojIntegration tests that generally require a configured SQL Server or Azure SQL target.

These projects target net8.0, net9.0, and net10.0 on all platforms. On Windows, they also target net462.

Recommended Entry Point

Use build.proj from the repository root:

dotnet build build.proj -t:<test_target> [optional_parameters]

Since build.proj is the only project file in the repo root, it can be omitted when building from the root:

dotnet build -t:<test_target> [optional_parameters]

The command-line examples below will assume that build.proj is selected by default and will omit it from the dotnet build command.

Test targets build the projects they depend on, so a separate build step is not required for normal test runs.

Test Targets

TargetDescription
TestRuns all test targets in the repository. This can take a long time and is not recommended for routine local development.
TestAbstractionsRuns Microsoft.Data.SqlClient.Extensions.Abstractions tests.
TestAzureRuns Microsoft.Data.SqlClient.Extensions.Azure tests.
TestSqlClientRuns all Microsoft.Data.SqlClient test projects.
TestSqlClientUnitRuns Microsoft.Data.SqlClient unit tests.
TestSqlClientFunctionalRuns Microsoft.Data.SqlClient functional tests.
TestSqlClientManualRuns Microsoft.Data.SqlClient manual tests.

Common Commands

Run the SqlClient unit tests:

dotnet build -t:TestSqlClientUnit

Run the SqlClient functional tests:

dotnet build -t:TestSqlClientFunctional

Run the SqlClient manual tests:

dotnet build -t:TestSqlClientManual

Run only manual test set 2:

dotnet build -t:TestSqlClientManual -p:TestSet=2

Run manual test sets 1 and 3:

dotnet build -t:TestSqlClientManual -p:TestSet=13

Run Always Encrypted manual tests:

dotnet build -t:TestSqlClientManual -p:TestSet=AE

Run a specific target framework:

dotnet build -t:TestSqlClientFunctional -p:TestFramework=net8.0

Run functional tests against an x86 dotnet installation:

dotnet build -t:TestSqlClientFunctional -p:DotnetPath='C:\path\to\dotnet\x86\'

Run all Azure extension tests, including interactive tests, while still excluding tests marked failing or flaky:

dotnet build -t:TestAzure -p:TestFilters=category!=failing

Test Parameters

The most commonly used test parameters are:

ParameterDefaultDescription
-p:Configuration=DebugBuild configuration. Use Debug or Release.
-p:DotnetPath=EmptyPath to the folder containing the dotnet binary. The path must end with \ or /.
-p:ReferenceType=ProjectFor functional and manual SqlClient tests, use Project to test the source project or Package to test a package reference.
-p:TestBlameTimeout=10mEnables hang blame collection with the specified timeout. Use 0 to disable hang timeouts.
-p:TestCodeCoverage=trueCollects code coverage when set to true.
-p:TestFilters=category!=failing&category!=flaky&category!=interactivexUnit filter expression. Use none to run without the default filter.
-p:TestFramework=EmptyTarget framework to run. If omitted, all target frameworks supported by the project and host OS are run.
-p:TestResultsFolderPath=test_resultsDirectory where test results are written.
-p:TestSet=EmptySelects manual test sets. Supported values include 1, 2, 3, AE, and combinations such as 13 or 12AE.

Test Filters

build.proj passes TestFilters to dotnet test --filter. By default, tests marked with these categories are excluded:

CategoryWhy it is excluded by default
failingKnown failing tests.
flakyIntermittently failing tests.
interactiveTests that require user interaction or external setup not suitable for normal runs.

Examples:

Run a single test by fully-qualified name:

dotnet build -t:TestSqlClientUnit -p:TestFilters=FullyQualifiedName=Namespace.ClassName.MethodName

Run only flaky tests while investigating quarantine failures:

dotnet build -t:TestSqlClientManual -p:TestFilters=category=flaky

Disable the default filter:

dotnet build -t:TestSqlClientFunctional -p:TestFilters=none

When passing filter expressions that contain shell-sensitive characters such as &, quote or escape the value as required by your shell.

Running Test Projects Directly

build.proj is the recommended entry point because it keeps logging, code coverage, package-reference mode, and common parameters consistent. For quick local investigation, you can run a test project directly:

dotnet test src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj \
  -p:Configuration=Debug \
  --filter "category!=failing&category!=flaky&category!=interactive"

For manual tests, pass TestSet to the test project when needed:

dotnet test src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTests.csproj \
  -p:Configuration=Debug \
  -p:TestSet=2 \
  --filter "category!=failing&category!=flaky&category!=interactive"

Manual Test Prerequisites

Manual tests require SQL Server or Azure SQL resources and a local test configuration file.

For a basic local SQL Server run, prepare:

Feature-specific tests require additional resources. If those resources are not configured, the corresponding conditional tests are skipped.

Manual Test Configuration

Edit the source configuration file at src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/ config.jsonc. The test utilities project copies that file to the test output directory, where the manual tests load it by default.

The template file is:

src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.jsonc

config.jsonc is git-ignored. If it does not exist, the test utilities project copies config.default.jsonc to config.jsonc before compile. You can also create it manually:

cp src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.jsonc \
  src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.jsonc

Update config.jsonc for your environment before running manual tests. The most important values for a basic run are TCPConnectionString and NPConnectionString.

{
  "TCPConnectionString": "Data Source=tcp:localhost;Database=Northwind;Integrated Security=true;Encrypt=false;",
  "NPConnectionString": "Data Source=np:localhost;Database=Northwind;Integrated Security=true;Encrypt=false;",
  "EnclaveEnabled": false,
  "TracingEnabled": false,
  "SupportsIntegratedSecurity": true
}

For SQL Server in a Linux container, WSL, or another host where SQL authentication is easier than integrated security, use a TCP connection string like:

{
  "TCPConnectionString": "Data Source=tcp:127.0.0.1;User Id=sa;Password=<password>;Database=Northwind;Encrypt=false;TrustServerCertificate=true"
}

You can override the config file path with the TEST_MDS_CONFIG environment variable:

TEST_MDS_CONFIG=/path/to/config.jsonc dotnet build -t:TestSqlClientManual -p:TestSet=2

On PowerShell:

$env:TEST_MDS_CONFIG = "C:\path\to\config.jsonc"
dotnet build -t:TestSqlClientManual -p:TestSet=2

Configuration Properties

PropertyDescriptionExample or notes
TCPConnectionStringConnection string for a TCP-enabled SQL Server or Azure SQL database.Data Source=tcp:localhost;Database=Northwind;Integrated Security=true;Encrypt=false;
NPConnectionStringConnection string for a Named Pipes-enabled SQL Server instance.Data Source=np:localhost;Database=Northwind;Integrated Security=true;Encrypt=false;
TCPConnectionStringHGSVBSOptional connection string for SQL Server with VBS enclave and HGS attestation.Include Attestation Protocol=HGS and Enclave Attestation Url.
TCPConnectionStringNoneVBSOptional connection string for SQL Server with VBS enclave and no attestation.Include Attestation Protocol=None.
TCPConnectionStringAASSGXOptional connection string for SQL Server with SGX enclave and Microsoft Azure Attestation.Include Attestation Protocol=AAS and Enclave Attestation Url.
EnclaveEnabledEnables tests that require an enclave-configured server.true or false.
TracingEnabledEnables tracing-related tests.true or false.
AADAuthorityURLOptional OAuth authority for AADPasswordConnectionString.https://login.windows.net/<tenant>
AADPasswordConnectionStringOptional connection string for Microsoft Entra ID password authentication tests.Uses Authentication=Active Directory Password.
AADServicePrincipalIdOptional application ID for service-principal authentication tests.Former docs may refer to this as a secure principal ID.
AADServicePrincipalSecretOptional application secret for service-principal authentication tests.Keep this only in local, ignored config files or secure pipeline variables.
AzureKeyVaultURLOptional Azure Key Vault URL for Always Encrypted tests.https://<keyvaultname>.vault.azure.net/
AzureKeyVaultTenantIdOptional Entra ID tenant ID for Azure Key Vault tests.Tenant ID GUID.
SupportsIntegratedSecurityWhether the user running tests has integrated-security access to the target SQL Server.true or false.
LocalDbAppNameOptional LocalDB instance name. Empty disables LocalDB testing.MSSQLLocalDB or another local instance.
LocalDbSharedInstanceNameOptional shared LocalDB instance name.Used only when testing shared LocalDB.
FileStreamDirectoryDirectory used for FileStream database setup.Use an escaped absolute path in JSON.
UseManagedSNIOnWindowsEnables Managed SNI on Windows test coverage.true or false.
DNSCachingConnStringOptional connection string for DNS caching tests.Used with DNS caching server settings.
DNSCachingServerCROptional DNS caching control-ring server.Feature-specific tests only.
DNSCachingServerTROptional DNS caching tenant-ring server.Feature-specific tests only.
IsDNSCachingSupportedCREnables DNS caching control-ring tests.true or false.
IsDNSCachingSupportedTREnables DNS caching tenant-ring tests.true or false.
EnclaveAzureDatabaseConnStringOptional Azure SQL database connection string for enclave tests.Feature-specific tests only.
ManagedIdentitySupportedWhether managed identity tests should run.Defaults to true. Set false if unavailable.
UserManagedIdentityClientIdOptional client ID for user-assigned managed identity tests.Feature-specific tests only.
KerberosDomainUserOptional Kerberos test domain user.Feature-specific tests only.
KerberosDomainPasswordOptional Kerberos test domain password.Keep only in local, ignored config files or secure pipeline variables.
IsManagedInstanceMarks the target as Azure SQL Managed Instance.Set true for Managed Instance to use non-Azure TVP baseline files in test set 3.
PowerShellPathFull path to PowerShell if it is not on PATH.C:\\escaped\\path\\to\\powershell.exe
AliasNameOptional SQL Server alias used by alias-related tests.Feature-specific tests only.

Manual Test Sets

The manual test project is split into compile-time sets so large runs can be parallelized.

TestSetCoverage
1Smaller SQL connectivity and command scenarios.
2Broad data access coverage, including adapters, bulk copy, retry logic, data reader, schema, DNS caching, and related scenarios.
3Additional integration coverage, including LocalDB, pooling, parameters, transactions, JSON, Kerberos, UDT, vector, and other SQL feature tests.
AEAlways Encrypted tests.

If TestSet is omitted, all sets are compiled and run. You can combine sets by concatenating values, for example -p:TestSet=23 or -p:TestSet=12AE.

Results and Diagnostics

Test results are written to the test_results directory by default. Override the location with TestResultsFolderPath:

dotnet build -t:TestSqlClientUnit -p:TestResultsFolderPath=/tmp/sqlclient-test-results

Hang blame collection is enabled by default with a 10m timeout. To increase the timeout:

dotnet build -t:TestSqlClientManual -p:TestBlameTimeout=30m

To disable hang blame collection:

dotnet build -t:TestSqlClientManual -p:TestBlameTimeout=0

Code coverage is enabled by default. To disable it for a faster local run:

dotnet build -t:TestSqlClientUnit -p:TestCodeCoverage=false