Export (0) Print
Expand All

SQL Server Unit Test Files

Like the unit tests for managed code, SQL Server unit tests reside in test projects. You can see the items that compose a SQL Server unit test in the hierarchy of a test project in Solution Explorer .

A SQL Server unit test consists of multiple items that are contained in several files. The following table describes the files that interact to form a SQL Server unit test.

 

File Description

.cs or .vb

This source-code file contains a class that is decorated with the [TestClass] attribute. This class contains a single test method for each of the contained SQL Server unit tests. These methods are decorated with the [TestMethod] attribute.

Each test method contains the appropriate code to exercise the Transact-SQL test script. This code is generated when the test methods are created, and you can modify it.

noteNote:
If you double-click this file in Solution Explorer , the test class opens in the SQL Server Unit Test Designer. To open the .cs or .vb file to see its source code, right-click the file in Solution Explorer , and then click View Code .

.resx

This resource file contains the Transact-SQL scripts for all tests in the associated .cs or .vb file. This group of scripts includes the pre-test script, the test script, and the post-test script. The resource file contains XML, which you can edit. The resource file is compiled into the test assembly.

You should code your Transact-SQL scripts by using the SQL Server Unit Test Designer . For more information about the scripts that are used in SQL Server unit tests, see Scripts in SQL Server Unit Tests.

app.config

This file stores the database connection strings for the test project, in addition to other SQL Server unit test configuration settings such as command time-out. For more information, see Scripts in SQL Server Unit Tests.

SQLDatabaseSetup.cs or SQLDatabaseSetup.vb

This file contains a class that prepares the test environment for all SQL Server unit tests in the test project. Based on the configuration settings in the app.config file, it may deploy a SQL Server Database Project to the test database.

See Also



Show:
© 2014 Microsoft