Questions tagged [tsqlt]

tSQLt – The Database Unit Testing Framework for SQL Server

tSQLt is a database unit testing framework for Microsoft SQL Server. tSQLt is compatible with SQL Server 2005 (service pack 2 required) and above on all editions. It is available at tSQLt.org

177 questions
89
votes
5 answers

The database owner SID recorded in the master database differs from the database owner SID

When I try to install tSQLt onto an existing database i get the following error: The database owner SID recorded in the master database differs from the database owner SID recorded in database ''. You should correct this situation by resetting…
JDPeckham
  • 2,288
  • 2
  • 22
  • 24
14
votes
3 answers

Unable to create the tSQLtCLR assembly in SQL Server 2017

I recently installed SQL Server 2017 Express and localdb (general availablity). While attempting to install the tSQLt framework I've discovered a new security feature implemented in SQL Server 2017: the "clr strict security" option. This new…
Brent
  • 143
  • 1
  • 1
  • 5
13
votes
2 answers

SQLCop tests for tSQLt

The Redgate tool SQLTest for SQL unit testing now offers the ability to add tests from SQLCop however the Redgate tool only comes with few of those tests prebuild. Since tests are just stored procedures I am sure somebody has implemented more of…
lstanczyk
  • 1,195
  • 12
  • 19
13
votes
5 answers

How do I recover when tSQLt faketable does not reset table mapping?

faketable function did not reassign to normal. All my tables I used faketable on now contain the content of the values I used in the insert of the unit test. It was many tables and it has left my database useless. Please help address this problem…
zdGastineau
  • 191
  • 2
  • 5
10
votes
3 answers

TSQL Unit Test tools 2017: SQL Server Data Tools 2017 vs tSQLt

I have a new project that needs SQL Server unit test, and CI/CD with VSTS. Below is the features that are required SQL server unit test against stored procedure, initial target tables setup for each test and clean up Unit test in sql CI/CD with…
10
votes
2 answers

tsqlt - create separate database for unit testing

I have started using tsqlt, and my question is it possible to have a separate database with just the testing stuff? (tables/sp's/assemblies etc). This testing database will sit on the same instance as the actual/target database. If I try to fake a…
Umair
  • 2,877
  • 1
  • 23
  • 46
9
votes
1 answer

Running tSQLt project from sources fails on the due to the Public Token mismatch

I'm trying to do some improvements for tSQLt framework and I'm mostly finish, but can't do that as few tests related to the certificate I wasn't touching are still failing: [exec] |18|[InstallExternalAccessKeyTests].[test creates correct…
Dmitrij Kultasev
  • 4,760
  • 2
  • 34
  • 70
8
votes
2 answers

Unit testing with tSQLt on computed columns

I’ve been writing some tSQLt database unit tests (via Red Gate SQL Test) on procedures which call tables containing (persisted) computed columns recently, and note that if I use the FakeTable SP, I find that the computed columns are not populated…
DaveGreen
  • 704
  • 6
  • 12
8
votes
3 answers

Unit testing of SSIS Package with tSQLt

I really like tsqlt to test procs and functions, but really would like to be able to also execute SSIS packages and take advantage of FakeTable and AssertEquals to determine if it was the SSIS package did what it was supposed to. Has anyone explored…
duyker
  • 800
  • 8
  • 17
7
votes
4 answers

tSQLt.FakeTable doesnt seem to work with views that have constants/derived fields

exec tSQLt.SetFakeViewOn 'dbo.viewWithIssues'; GO CREATE PROCEDURE TestChanges.[Test Data] AS BEGIN ... exec tSQLt.FakeTable 'dbo.viewWithIssues', @identity=1, @ComputedColumns=1, @Defaults=1; INSERT INTO dbo.viewWithIssues (clock_id,…
zeroshi
  • 99
  • 5
6
votes
4 answers

How to ROLLBACK a transaction when testing using tSQLt

I recently was calling a procedure that contained a rasierror in the code. The raiserror was in a try catch block. Also a BEGIN TRAN was in the same try catch block after the raiserror. The Catch block is designed to ROLLBACK the transaction if…
zdGastineau
  • 191
  • 2
  • 5
6
votes
1 answer

How do I ignore a column in a tSQLt AssertEqualsTable?

Is it possible to ignore certain columns that are almost definitely going to be different in a tSQLt AssertEqualsTable? Examples would be primary keys from the two results tables, insert/update date stamps, and so on. I have been working around this…
Alex
  • 2,563
  • 2
  • 26
  • 41
6
votes
3 answers

tSQLt TRUSTWORTHY and CLR requirement

The tSQLt test framework requires to set TRUSTWORTHY ON for the database, and to enable SQL CLR for the server. Why are these required? Is it possible to achieve the same/similar functionality without a CLR object?
Justin Caldicott
  • 559
  • 7
  • 21
5
votes
2 answers

There was also a ROLLBACK ERROR and tSQLt.ExpectException

Here is the scenario: Stored procedure sproc_a calls sproc_b. Then sproc_b calls sproc_c. A typical nested procedure. Sproc_a did a SET XACT_ABORT ON; and used named transaction. Sproc_c raised an error. tSQLt.ExpectException failed to…
sakadas
  • 469
  • 4
  • 13
5
votes
2 answers

How do I mock/fake a RaiseError with in a StoredProcedure

This is my first day with tsqlt so you can expect some vague statements. I am trying to test a storedProcedure which has a Try Catch Block but the actual statements in test are insert and update command. now I want to test if in case there was an…
Muds
  • 3,754
  • 5
  • 25
  • 46
1
2 3
11 12