Installing tSQLt Faqs

72 views
Skip to first unread message

Upendar Avireni

unread,
Oct 8, 2020, 12:14:44 PM10/8/20
to tSQLt
Hi All,

I'm using Redgate SQL source control 7 for our SQL code in SQL 2016 server with in SSMS and using shared development model. Redgate SQL Test 4 is with in SSMS to do SQL code unit testing with the help of tSQLt. 
So while installing, we're able to 'clr enabled' on db server and TRUSTWORTHY ON target db. Then while creating example database, got the error "DBAs will not support assembly implementation" and leads to Assembly 'tSQLtCLR' not created. So we're thinking to execute 'tSQLt.class' script on our target db as it might give the same error.

I want to whether tSQLt should be installed on DB server or developer machine ?
Please suggest on steps to install it and start using with in SQL Test.

Thanks,
Upendar

Sebastian Meine

unread,
Oct 8, 2020, 1:12:50 PM10/8/20
to ts...@googlegroups.com
tSQLt should only be installed in development environments, never in production. 

Usually that is the developer machines and Sql servers in a CI/CD pipeline. 




--
You received this message because you are subscribed to the Google Groups "tSQLt" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tsqlt+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tsqlt/2984d2e7-77a7-4d04-954c-724cd2542976n%40googlegroups.com.
--
Thanks,

Sebastian
Message has been deleted
Message has been deleted

Upendar Avireni

unread,
Oct 9, 2020, 5:47:28 AM10/9/20
to tSQLt
And Our DB server is in different machine & we're connecting through SSMS v17.9.1
We're using Azure Devops for CI/CD pipelines for SQL code deployment. Redgate SQL change automation build task using for building sql code.
So Could you tell me tSQLt should be installed in developer machine or sql server ?  

Dave Boltman

unread,
Oct 9, 2020, 6:10:45 AM10/9/20
to Upendar Avireni, ts...@googlegroups.com
Hi  Upendar,

And Our DB server is in different machine & we're connecting through SSMS v17.9.1
We're using Azure Devops for CI/CD pipelines for SQL code deployment. Redgate SQL change automation build task using for building sql code.
So Could you tell me tSQLt should be installed in developer machine or sql server ?

Have tried installing tSQLt on your developer machine? tSQLt only exists inside a SQL Server database. It is impossible to install it on a developer machine unless that machine has SQL Server running on it

Many Thanks
Dave Boltman


Upendar Avireni

unread,
Oct 9, 2020, 6:26:47 AM10/9/20
to tSQLt

Hi, I'm a developer and have downloaded the above tSQLt framework tool 1.0.5873.27393 into my local.
then 'clr enabled' on db server and TRUSTWORTHY is on target db.
I'm using Redgate SQL Test4 included SSMS v17.9.1 and I think installed tSQLt as below.


So now I should execute 'tSQLt.class' script on our target database ? correct me If I'm wrong. thanks

Sebastian Meine

unread,
Oct 9, 2020, 1:45:25 PM10/9/20
to ts...@googlegroups.com
Yes. tSQLt needs to be installed in every database that does/ will contain tests. 

Sebastian

--
Thanks,

Sebastian

Upendar Avireni

unread,
Oct 13, 2020, 8:55:16 AM10/13/20
to tSQLt
Thanks Sebastian.

I have installed tSQLt on source database. will start writing the SQL unit tests.

We're using Redgate SQL source control integrated with SSMS for pushing the code to Azure Devops and using Redgate SQL change automation:build task for CI build and GIT as version control. Now using SQL Test as GUI for tSQLt tests. Could you please let me know how do I make these test results(code coverage) would be part of CI build pipeline ? 
Thanks

Upendar Avireni

unread,
Oct 14, 2020, 9:53:39 AM10/14/20
to tSQLt
Hi Team,
We're using Redgate for build/release of SQL code. I heard tSQLt tests results xml file. 
How could we convert this xml file into code coverage ? Do we need any other tool for this code coverage ?

Sebastian Meine

unread,
Oct 14, 2020, 4:58:21 PM10/14/20
to ts...@googlegroups.com
Code coverage in SQL test is provided through a separate tool, not tSQLt. Therefore the tSQLt result file won’t contain the coverage results. 

Sebastian

--
Thanks,

Sebastian

Pavel Kardash

unread,
Oct 16, 2020, 6:09:25 PM10/16/20
to tSQLt
What work management tool are you using?
You could get a report on what tests ran and what tests failed. We are using it in Azure DevOps CI/CD pipeline, but indeed there is no Test Coverage there. From what I gather, you probably don't want to publish this metric. Think of it. Code Coverage just talks about covering the code with at least one test for some object (could even drill into what line in the object is tested). But it won't surface out the different variations that need to be tested on that object/line of object to guarantee the quality of it. Makes sense?
This is something I have also seen mentioned by Ted somewhere.

Upendar Avireni

unread,
Oct 19, 2020, 6:29:31 AM10/19/20
to tSQLt
Our main aim to integrate SQL code coverage % into Sonarqube dashboard, which we're following the same for C#, .net code. We're using Azure DevOps CI/CD pipeline(Redgate SQL change automation:build task) for building sql code. We'll be using "Test a build artifact from a SQL Source Control project using tSQLt tests" operation to include tSQLt tests in our pipeline, so thought what would the output of these and how could the same integrated into sonarqube dashboard ? Please advise. 

Upendar Avireni

unread,
Nov 6, 2020, 6:56:46 AM11/6/20
to tSQLt
Hi Team,

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 published to Tests summery. But code coverage is not showing. We want to show the this code coverage and want to integrate this coverage with in Sonarqube dashboard. 

Kindly suggest on how could we do this. Thanks.

Fiona Rodgers

unread,
Dec 16, 2020, 7:00:19 PM12/16/20
to tSQLt
I'm trying to convince my company to install tSQLt onto my QA db in the dev environment.  Does anyone have any idea what are the security risks?

SgtWilko

unread,
May 12, 2021, 7:10:46 PMMay 12
to tSQLt
We are also trying to integrate the code coverage into Sonar.
The issue seems that despite Redgate Supporting the SQL Cover project, they haven't included SQL Cover in the Azure Redgate tasks!

We're publishing to a nuget package then running the tests on that.
I've not yet found a trick where I can create a temp SQL Server, install SQL Cover, install the nuget into the temp server and run the tests (but last time I tried it was about 6 months back)

If anyone manages to get it working Please post here!

Sebastian Meine

unread,
May 12, 2021, 10:05:37 PMMay 12
to ts...@googlegroups.com
Fiona,

It has been a while since you asked the question. If you're still looking for an answer, let me try to provide one:

tSQLt is in part based on CLR code. As such, you have to enable CLR on the instance in question. The newest version of tSQLt does not require any additional changes that could affect security.
However, to execute tests, you likely need db_owner permissions, as tests regularly create and alter existing objects in the database.

So much for security. However, and in general, I do not recommend installing tSQLt in a shared environment. While it should not cause security problems, because it is not really thread-safe it could cause other headaches best avoided.

Thanks,

Sebastian


Reply all
Reply to author
Forward
0 new messages