Questions tagged [tsqlt]

tSQLt – The Database Unit Testing Framework for SQL Server

Filter by
Sorted by
Tagged with
0 votes
1 answer
25 views

tSQLt - Install failed

I have downloaded the tSQLt and execute the PrepareServer.sql and received the error message below: Msg 208, Level 16, State 1, Procedure AuditLogDDLEvents, Line 8 [Batch Start Line 189] Invalid ...
user3624829's user avatar
1 vote
0 answers
42 views

tSQLt : How to compare result set (dynamic column return) from call stored procedure without define the structure table

Please help me to compare the result set(dynamic columns) from caller stored procedure without define the structure table using tSQLt SP: ALTER PROCEDURE [dbo].[spa_Test] @Param1 INT AS BEGIN ...
user avatar
1 vote
0 answers
62 views

T-SQL Calculate Turnover for Rolling 12 month from Staff_table and Leavers_Table

Hi I have two table one is holding list of employee the other table holding who is left the company. I need to do Turnover Calculation as : Average number of staff at the start and end of rolling ...
Mina's user avatar
  • 23
2 votes
1 answer
343 views

VS 2022 17.5.1 Project contains a reference to a project which is unloaded

I have upgraded from VS 2019 Community Edition to VS Community 2022 17.5.1. When trying to build the project, the system complains with various errors. These errors seem related to database references ...
Michael Aquilina's user avatar
2 votes
1 answer
329 views

Setup Azure SQL database unit test DevOps environment with tSQLt

Environment Server with Azure SQL Local with SQL Server Express Database deploy with SSDT The plan [Developer] Run database unit test locally on SQL Server Express during development [DevOps] Once ...
Bill's user avatar
  • 336
0 votes
2 answers
105 views

Is Red Gate SQL Test tSQLt version the same as in GitHub?

Part 1 of my question is: I'm trying to find the benefits in buying Red Gate SQL Test VS simply using the free tSQLt on its own. I already saw 2 similar questions that were answered by Red Gate who ...
Ronit's user avatar
  • 3
0 votes
1 answer
101 views

How to run tSQLt in a specific order and make it dependent test?

Is there any way to run tests within tSQLt test class in a specific order? To my knowledge, every test is run within a transaction (meaning at the end all data will be rollback). Can we make dependent ...
FIDEL's user avatar
  • 1
0 votes
1 answer
186 views

Tsqlt tests are failing even though Expected and Actual tables have same values

I am getting error failed: (Failure) Unexpected/missing resultset rows! for tsqlt tests even though Expected and Actual table has same result volume 90Dayvolume Relative90Dvol 4493 16413368.1429 95....
Himani's user avatar
  • 39
0 votes
2 answers
97 views

Is there a short hand method of retrieving a value from a function in an insert?

I have some tSQLt tests which are using magic numbers for some static data IDs and I'm trying to make them more self documenting by using a function. Currently I'm using this but it's a bit more wordy ...
Inverted Llama's user avatar
0 votes
0 answers
108 views

SqlPackage failing - [sys] reference not resolved

Im try to execute our db unit tests during PR builds. I have a solution with the main database project and a unit test project that references it, plus master. I can run SqlPackage on my local ...
Jonesie's user avatar
  • 7,057
1 vote
3 answers
130 views

Required permission to use tSQLt on SQL Server

Is there any other way to run tSQLt on a SQL Server database without sysadmin role or ALTER TRACE permission? We are currently trying to use a test tool called SQLTest from Redgate which uses the ...
MWNewbie's user avatar
0 votes
0 answers
63 views

tSQLt testing between source and destination database

I have data loaded from Oracle DB to SQL Server every day via SSIS job. I have asked to verify in tSQLt whether a number of records on oracle DB loaded correctly in SQL Server. How can I do this ...
jslover2020's user avatar
0 votes
2 answers
221 views

Exec tSQLt.Faketable crashing our original table constraint and data

During debugging the tsqlt code, I have directly run the below statement without wrapping it as sp and my original table constraint got deleted and some data missing from the original table. Exec ...
jslover2020's user avatar
0 votes
1 answer
425 views

tSQLt V1.0.8083.3529 will not build in Visual Studio 2022

I have a database test project and tSQLt has an error when I do a build: SQL71501: View: [tSQLt].[Private_HostPlatform] has an unresolved reference to object [sys].[dm_os_host_info].[host_platform]. ...
David Demland's user avatar
0 votes
0 answers
76 views

My tSQLt scripts gets overwritten when prod db refresh happens? How to persist the tsqlt script?

I have tsqlt installed on lower environments and I have created my tsqlt for the unit testing. But right now, we don't promote tSQLt to production since we are not allowed to install tSQLt in ...
Maya Doug's user avatar
0 votes
1 answer
64 views

does tSQLt support comparing two JSON strings?

I am using tSQLt to test stored procedures which output JSON string results. The problem I have is that the key/value pairs in JSON are not always the same order. For example, JSON1: {"A":1, ...
Agim's user avatar
  • 1
0 votes
0 answers
75 views

Does tSQLT needed the database should set TRUSTWORTHY ON?

Is database TRUSTWORTHY ON necessary for tSQLt to run? In our DB environment, we can't set TRUSTWORTHY ON for databases. Does tSqlt run with the database status of TRUSTWORTHY OFF?
Maya Doug's user avatar
0 votes
0 answers
92 views

Can tsqlt table accessed outside of tSqlt scope?

I am writing a tsqlt unit testing where I am not faking the table and I am using the real SQL table ex:sendEmail to test the email sending functionality. I am inserting the value like below from tsqlt ...
Maya Doug's user avatar
1 vote
1 answer
3k views

How can I use a case statement that includes a wildcard

I have tried to include a wildcard in the below Case statement with no good result. CASE WHEN store IS NULL THEN ( CASE WHEN location IN (‘A%’, ‘B%’’ ‘C%’) ...
Truelife12's user avatar
0 votes
1 answer
154 views

What order the test cases run in the tSQLt?

I have 30 test cases in the 'EmployeeSchema'. I want to know in which order the test cases run in the tSqlt? If I know the order of execution of test cases, then I alter the execution order of my test ...
Maya Doug's user avatar
0 votes
1 answer
116 views

tSQLt.AssertEqualsTable takes hours to complete when big data set involves

EXEC tSQLt.AssertEqualsTable 'expected', 'actual'; I am comparing expected vs actual tables. This table has 100k plus records and if 80k records match 20k records don't match then tsqlt will paint ...
Maya Doug's user avatar
0 votes
1 answer
89 views

Unit Testing Case Statements

I appreciate this probably isn't the place to ask, if there is a better place please let me know. I have a legacy Stored Procedure that selects some data and inserts into a table. However there are ...
mickeysox's user avatar
  • 181
1 vote
0 answers
82 views

tSQLt.Fail does not make test fail

I created a test like this: CREATE PROCEDURE MyTestClass.[test example01] AS BEGIN EXEC tSQLt.Fail 'Not implemented'; END; However, when I run the test the result is Success. What am I doing ...
Test User's user avatar
1 vote
2 answers
174 views

How to use tSQLt to test if a integer value is within a specific range?

I'm using the tSQLt unit testing tool. I want to test if an actual row count is within .1% of an expected value. Seems like I could use a EXEC tSQLt.AssertIntValueInRange procedure, but I couldn't ...
Eric B's user avatar
  • 75
0 votes
1 answer
76 views

Mock SERVERPROPERTY in tSQLt

I am writing some logic that has branches based on the SQL Server version. Is there a way to mock SERVERPROPERTY in tSQLt? Edit: Updated question and description with correct function name.
tarun_'s user avatar
  • 9
1 vote
1 answer
217 views

Using tSQLt AssertEqualsTableSchema in a test procedure that contains TRY/CATCH

It seems that the SQL test framework tSQLt does not allow to use an assertion such as tSQLt.AssertEqualsTableSchema after a TRY/CATCH block that generates an error. If I try that, the test generates ...
pygri's user avatar
  • 657
0 votes
1 answer
939 views

How to fix this error: Msg 50000, Level 17, State 2, Procedure tSQLt.FakeTable, Line 13 [Batch Start Line 0] Please run this inside a unit test

I am currently working on my SQL Server project unit testing using TSQLT and I'm getting the below error, and don't know how to fix it. Has anyone faced it before? Can anyone suggest a tutorial for ...
ManojN's user avatar
  • 17
0 votes
0 answers
241 views

tSQLt failure when attempting to SpyProcedure a synonym SP

I am new to tSQLt. I am writing a test for a stored procedure that calls an sp on a different DB. This external SP is set as a synonym in the DB I use. To enhance, this is what I have: SP1 on DB1 SP2 ...
Noga's user avatar
  • 1
0 votes
1 answer
67 views

How Does FakeTable Work with the COLUMNS_UPDATED() function?

I have a 300+ column table and a trigger. I have 40(ish) "columns of interest" and the rest I don't care about. The purpose of the trigger is to determine if any of the "columns of ...
alaspin's user avatar
0 votes
1 answer
126 views

committing both live code and tsqlt tests

My company has recently started using tSQLt to test our codebase. We've built a few good test suites and now we're trying to figure out the best way to commit them. We're using an SQL server with ...
Scott Loney's user avatar
0 votes
0 answers
63 views

tSQLt.AssertEqualsTable order mismatch error

i am try to run one test, I got below error, So can you guys pls help me on this to fix this? pub_id avg_price 0736 9.784 0877 15.41 1389 18.976 ALL 14.7662 CREATE PROCEDURE ...
Rathinavel Palanisamy's user avatar
0 votes
1 answer
163 views

tsqlt spyProcedure with multiple output parameters

There is a related post to my question dealing with a single output parameter, but I cannot find a way to apply that to my procedure which has multiple output parameters. An overview of the procedure ...
David's user avatar
  • 13
0 votes
1 answer
285 views

How does one handle scope identity statements in T-SQL T?

There doesn't seem to be any way to Fake a table then have the SCOPE_IDENTITY function run on the faked table. Take this statement (inside a stored procedure) INSERT INTO [dbo].[SomeTable](Id1, Id2) ...
The Unculled Badger's user avatar
3 votes
1 answer
506 views

Publishing test results to Azure (VS Database Project, tSQLt, Azure Pipelines, Docker)

I am trying to fully automate the build, test, and release of a database project using Azure Pipeline. I already have a Visual Studio solution which consists of three database projects. The first ...
BrokenBad's user avatar
1 vote
2 answers
1k views

Create a temporary table dynamically from calling an stored procedure

I want to create a temporary table from calling a stored procedure as something like below Select * into #temp1 from exec sp1; or select * into #temp1 from sys....
user13875967's user avatar
0 votes
2 answers
143 views

TSQLT Asserting stored procedure column names

Is there a way for tsqlt to assert all the columns returned from a stored procedure have a certain column name? I need to check if Employee_lname column actually returns as 'Employee_lname' instead ...
Phanzy Phan's user avatar
0 votes
0 answers
82 views

Line vs Statement coverage in SQL Cover

I am trying to use SQL Cover library in my project to find the code coverage, I have tried using Redgate SQL Test previously for same purpose but with SQL cover the number of lines are almost double ...
vaps's user avatar
  • 21
1 vote
2 answers
112 views

Can I integrate Redgate SQL Test directly with teamcity to get code coverage

I have purchased Redgate SQL Test, I need to integrate same with Teamcity. Can i achieve it without any other licensed softwares from Redgate.
vaps's user avatar
  • 21
0 votes
1 answer
89 views

Is there a way to assert a "not" condition using tSQLt?

I am new to using tSQLt and struggling a bit with the available assert functions. The tSQLt.AssertEmptyTable method is great, but how do you apply a "not" condition to this, i.e. I want to ...
Chris Nachand's user avatar
1 vote
0 answers
348 views

Code coverage of SQL unit testing with tSQLt tool and integrating in Sonarqube dashboard

We're using tSQLt for SQL unit test cases and integrated with Azure DevOps for build pipeline using Redgate SQL Change Automation:build task. Now I got result as "TestResults.junit.xml" and ...
Upendar Avireni's user avatar
0 votes
1 answer
160 views

tSQLt testing isnt working while my teachers is

For school we are working on tests for a project. The test my teacher gave me works with no problem: EXEC tSQLt.NewTestClass 'testMaxPresidents1'; GO CREATE PROCEDURE [testMaxPresidents1].[test die ...
Clumsywolfy's user avatar
0 votes
3 answers
852 views

Get missing columns from a list of expected columns in a table

The test has a list of expected columns which verifies if the actual table has them. The assertion is if the counts are equal in expected and actual, then all columns are present. How to extract which ...
k_rollo's user avatar
  • 5,344
1 vote
3 answers
1k views

How to view test results in tSQLt?

We are using tSQLt for unit testing our database and executed below: EXEC tSQLt.Run '[testComplianceDimensions].[test CountOfPropertiesWithLatestRepairJob]' EXEC tSQLt.Run '[testComplianceDimensions].[...
k_rollo's user avatar
  • 5,344
0 votes
1 answer
66 views

tSQLt.run does nothing in one Query window but works in another

I have created 3 test classes. I can, from one query window run the following for all test classes. tSQLt.Run 'class1'; tSQLt.Run 'class2'; tSQLt.run 'class3'; But from all other query window, the ...
user3194853's user avatar
0 votes
2 answers
204 views

tSQLt.ExceptException is not working with rollback transaction in SQL Server

Below is my code snippet of a test case for a stored procedure my_proc to check not null parameter passed to the stored procedure. --faking required tables here --set values of parameters to be ...
user13875967's user avatar
0 votes
1 answer
616 views

Integration of tSQLt + SSDT into Jenkins

I am using SQL Server 2017 and Visual Studio 2019 Community edition. I have created my first SSDT project and configured it in Jenkins and I am facing issues while deploying it before running my tSQLt ...
user13875967's user avatar
0 votes
1 answer
164 views

tsqlt FakeTable not rolling back after unit test executed

I have an extremely simple unit test where I am testing the functionality of a tsqlt.FakeTable. However, after running the command and inserting data, it does not roll back to the previous state. ...
Michael Aquilina's user avatar
2 votes
1 answer
1k views

Using TSQLT FakeTable to test a table created by a Stored Procedure

I am learning to write unit tests for work. I was advised to use TSQLT FakeTable to test some aspects of a table created by a stored procedure. In other unit tests, we create a temp table for the ...
PolarVortex8's user avatar
0 votes
2 answers
372 views

tsqlt testing an output parameter from a stored procedure

I have a stored procedure that I am trying test for the proper generation of an output parameter. I experimented with tsqlt.ExpectException, but that did not work. I instead am trying tsqlt....
David's user avatar
  • 13
0 votes
1 answer
367 views

Must declare scalar variable in a unit test

I am trying to design a unit test that ensures that a message is bigger than a certain number of characters. My code is: EXEC tSQLt.NewTestClass 'TestMarketingEnoughRows'; GO CREATE OR ALTER ...
PolarVortex8's user avatar

1
2 3 4 5