tsqlt

Cannot import the following key file: tSQLtOfficialSigningKey.pfx when running building tSLQt

只愿长相守 提交于 2021-01-29 07:44:43
问题 I am trying to run tSQLt solution locally by following instructions in the tSQLt\Build\Install the tSQLt build.docx . Re-built tSQLtCLR solution: 1>------ Rebuild All started: Project: tSQLtCLR, Configuration: Debug Any CPU ------ 2>------ Rebuild All started: Project: tSQLtTestUtilCLR, Configuration: Debug Any CPU ------ 3>------ Rebuild All started: Project: tSQLtExternalAccessKey, Configuration: Debug Any CPU ------ 4>------ Rebuild All started: Project: UnsignedEmpty, Configuration: Debug

Unable to create the tSQLtCLR assembly in SQL Server 2017

…衆ロ難τιáo~ 提交于 2020-04-10 07:57:55
问题 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 security feature seems to prevent the creation of the tSQLtCLR assembly. The SQL error message states: CREATE or ALTER ASSEMBLY for assembly 'tSQLtCLR' with the SAFE or EXTERNAL_ACCESS option failed because the 'clr strict security' option of sp_configure

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

瘦欲@ 提交于 2020-03-17 05:55:08
问题 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 or at least its cause. This makes me very nervous about using this in our CI deployment process and maybe more importantly in our local development efforts. 回答1: It is possible one of your tests or your code, left the transaction in a state where it

TSQLT Returning Results from a Stored Procedure

爱⌒轻易说出口 提交于 2020-01-05 08:26:50
问题 In TSQLT, I'm trying to return a result from a stored procedure and add it to a variable so that I can assert if it matches my expected result. I've seen loads of examples of returning results from functions but none where a stored procedure is called. Does anybody have examples that they could share? Thanks in advance 回答1: If you want to get a variable back from a stored procedure one way to do this is to use an out parameter CREATE PROC MyTest (@myVar int output) AS BEGIN SET @myVar = 10

How to ROLLBACK a transaction when testing using tSQLt

断了今生、忘了曾经 提交于 2019-12-30 09:39:54
问题 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 the error occurred in the transaction. The way it does this is to check the @@TRANCOUNT if it is greater that 0 I know that it had started a transaction and needs to ROLLBACK. When testing with tSQLt the @@TRANCOUNT is always >0 so if it ever hits the

How to ROLLBACK a transaction when testing using tSQLt

余生颓废 提交于 2019-12-30 09:39:29
问题 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 the error occurred in the transaction. The way it does this is to check the @@TRANCOUNT if it is greater that 0 I know that it had started a transaction and needs to ROLLBACK. When testing with tSQLt the @@TRANCOUNT is always >0 so if it ever hits the

Possible with multiple database connections

余生颓废 提交于 2019-12-20 06:44:55
问题 New to the tSQLt world (great tool set) and encountered a minor issue with a stored procedure I am setting up a test for. If I for some reason have a stored procedure which connects to mutiple databases or even multiple SQL servers (Linked Servers). Is it possible to do unit tests with tSQLt in such a scenario? 回答1: I commented already, but I would like to add some more. So as I said already, that you can do anything that fits into the single transaction. But for your case I would suggest to

TSQLT unit test - The data types text and text are incompatible in the equal to operator

前提是你 提交于 2019-12-20 04:14:09
问题 I am getting this error from AssertEqualsTable "The data types text and text are incompatible in the equal to operator." then "The 'TableCompare' procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead." select * into #Actual from [dbo].[InvoiceOut]; --make expected table an empty table of #actual's structure because we truncate so it should be empty. SELECT TOP(0) * INTO #Expected FROM #Actual; EXEC tSQLt.AssertEqualsTable '#Expected', '

How do I rename a tSQLt test class?

∥☆過路亽.° 提交于 2019-12-18 17:05:18
问题 I'm developing a database using the Red Gate SQL Developer tools. SQL Test, the SSMS add-in that runs tSQLt tests, lacks a way to rename test classes. I have a test called [BackendLayerCustomerAdministrationTests].[test uspMaintainCustomerPermissions throws error when PermissionValue is missing or empty] . The name is so long it breaks Deployment Manager. 2013-12-05 18:48:40 +00:00 ERROR The specified path, file name, or both are too long. The fully qualified file name must be less than 260

How does impersonation and security permissions in tSQLt tests work?

馋奶兔 提交于 2019-12-13 03:07:55
问题 I have a tSQLt test which I expect to fail but it runs with success. When I run the code outside the procedure, it fails as expected, but when executing the test with Run, no error occurs. I have read the question tSQLt Testing SQL Server security permissions but the accepted answer does not solve my problem. My test looks like this: CREATE PROCEDURE TestSecurity.[test AFDK_Reader cannot read from AWS schema] AS BEGIN --EXEC tSQLt.ExpectException EXECUTE AS USER = 'AFDK_Reader' select * from