tsqlt-testing

Standardizes tSQLt unit testing for SQL Server stored procedures.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/jamesbondev/ai-dotfiles --skill tsqlt-testing-jamesbondev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tsqlt-testing
Source: https://github.com/jamesbondev/ai-dotfiles/tree/main/.github/skills/tsqlt-testing
Command: npx skills add https://github.com/jamesbondev/ai-dotfiles --skill tsqlt-testing-jamesbondev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide and checklist for writing robust, maintainable, and isolated unit tests for SQL Server stored procedures using the tSQLt framework, ensuring code quality and reliability.

Core Features & Use Cases

  • Test Structure & Naming: Enforces consistent naming conventions and organization for test classes and individual tests.
  • Isolation Techniques: Details the use of FakeTable, SpyProcedure, and FakeFunction to isolate tests from external dependencies.
  • Assertion Guidance: Explains various assertion types and provides patterns for validating results, especially for financial data.
  • Pitfall Avoidance: Highlights common mistakes like identity column loss and transaction rollback issues, offering solutions.
  • Use Case: When developing a new stored procedure for financial transactions, use this Skill to ensure all edge cases, such as insufficient funds or idempotency, are covered by well-structured tSQLt unit tests.

Quick Start

Review the provided checklist to ensure the tSQLt unit tests for the 'Banking.usp_TransferFunds' stored procedure adhere to all hard rules and best practices.

Frequently Asked Questions about tsqlt-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I isolate SQL Server stored procedure unit tests from external dependencies?

Isolate SQL Server stored procedure tests by applying tSQLt framework features like FakeTable, SpyProcedure, and FakeFunction to mock external dependencies. This ensures deterministic, verifiable results by preventing underlying schema changes from affecting test outcomes.

What are the best practices for tSQLt unit testing naming conventions and test structure?

tSQLt unit testing best practices enforce consistent naming conventions and logical organization for test classes and individual tests. Standardizing test structure improves maintainability and ensures that financial transaction edge cases are easily identifiable during code reviews.

How do I validate financial data and edge cases in SQL unit tests?

Validate financial data in SQL unit tests by applying specific tSQLt assertion strategies and patterns. These assertion types verify results for edge cases like insufficient funds or idempotency, ensuring stored procedures handle critical transactions reliably.

Why does tSQLt testing fail with identity column loss and transaction rollback issues?

tSQLt testing failures involving identity column loss and transaction rollback issues occur due to common isolation pitfalls. Applying targeted tSQLt strategies resolves these specific database testing constraints, ensuring tests remain isolated and deterministic.

Can I use tSQLt to expect and verify exceptions in SQL Server stored procedures?

Yes, you can use the tSQLt ExpectException feature to verify that SQL Server stored procedures throw expected errors under specific conditions. This assertion ensures error handling logic is robust and verifiable during database testing.