tSQLt Unit Testing Framework for Microsoft SQL Server

repository·main·Indexed 19 days ago

https://github.com/tsqlt-org/tsqlt

A unit testing framework for Microsoft SQL Server that allows developers to write and manage unit tests directly in T-SQL. It features automatic transactions for test independence, schema-based organization, and flexible output formats in plain text or XML for CI integration. Compatible with SQL Server 2005 (SP2 or higher) and all subsequent versions across all editions.

Tokens
539
Snippets
3
Records
4
Agent score
17%

What's inside tSQLt

  1. Overview of tSQLt unit testing framework

    main

    tSQLt is a unit testing framework specifically designed for Microsoft SQL Server. It allows developers to implement unit tests directly in T-SQL, eliminating the need to switch between different tools for application code and testing code.

    Key features include:

    • Automatic Transactions: Tests are automatically executed within transactions, ensuring test independence and minimizing manual cleanup work.
    • Schema-based Organization: Tests can be grouped into specific schemas, which facilitates organization and the use of common setup methods.
    • Flexible Output Formats: Test results can be generated in plain text or XML, facilitating easy integration with Continuous Integration (CI) tools.
  2. Install tSQLt snippets for Red Gate SQL Prompt

    main

    To use the provided tSQLt snippets within Red Gate SQL Prompt, unzip the snippet files into your local SQL Prompt Snippet Directory.

    Note: Red Gate SQL Prompt is a third-party tool and is not a requirement for using the tSQLt framework itself.

    Typical installation path:
    AppData\Local\Red Gate\SQL Prompt 6\Snippets
  3. Install tSQLt for Microsoft SQL Server

    main

    To use tSQLt, download the latest version from the official website.

    Compatibility Requirements:

    • SQL Server Version: Compatible with SQL Server 2005 (Service Pack 2 or higher) and all subsequent versions.
    • Editions: Works on all editions of Microsoft SQL Server.
    Download the latest version at http://tsqlt.org/downloads/
  4. Set up a development environment for building tSQLt

    main

    To build tSQLt locally, use a VS Code Dev Container to ensure all necessary build software is pre-configured.

    1. Clone the repository to your local machine.
    2. Ensure you have Visual Studio Code and Docker Desktop (or a compatible container platform) installed.
    3. Open the cloned folder in VS Code.
    4. Use the Command Palette to run Dev Containers: Open Folder in Container....

    This process initializes a development container containing the full toolchain required to build the project.

    git clone https://github.com/tsqlt-org/tsqlt.git