User Guide
This reference contains an explanation of each of the public tables, views, stored procedures and functions provided by tSQLt.
This reference contains an explanation of each of the public tables, views, stored procedures and functions provided by tSQLt.
Bad Behavior has blocked 875 access attempts in the last 7 days.
Hi.
How can i integrating tsqlt with Mstest runner on Visual studio 2012 ?
I think ResultSetFilter should be included on this page, maybe under “Test Creation and Execution”?
Thanks.
You are right. There are a few other ones missing too. I’ll probably add a tools section for those.
I’m looking for a way to run tests and persist results in my own custom fashion. tSQLt smartly rolls back every transaction (being a test suite, this makes sense). I’ve tried BEGIN TRAN/COMMIT TRAN inside my procedures for commands I don’t want rolled back – like additional logging, but I realize those transactions begin as a child of the tSQLt parent transaction.
Any suggestions?
You could use tSQLt.NewConnection to insert data into a table outside the current transaction. Be very careful however to not block yourself, as that will cause an undetectable deadlock.
Here is a demo:
CREATE TABLE dbo.tst(i INT)BEGIN TRAN
EXEC tSQLt.NewConnection 'INSERT dbo.tst(i) VALUES(13);';
ROLLBACK
SELECT * FROM dbo.tst;
DROP TABLE dbo.tst;
Pingback: Testy jednostkowe w SQL Server (tSQLt framework) – wprowadzenie i instalacja | Krzysztof Miodek
Pingback: Unit Testing SQL Scripts: tSQLt | Greg Swieringa
Method “AssertResultSetsHaveSameMetaData” Doesnt seem to work on SQL 2008 R2 / .NET framework 4. I get below error:
Msg 6522, Level 16, State 1, Procedure AssertResultSetsHaveSameMetaData, Line 0
A .NET Framework error occurred during execution of user-defined routine or aggregate “AssertResultSetsHaveSameMetaData”:
System.Data.SqlClient.SqlException: tSQLt.Failure
System.Data.SqlClient.SqlException:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQuerySmi(Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at tSQLtCLR.TestDatabaseFacade.assertEquals(String expectedString, String actualString)
at tSQLtCLR.MetaDataEqualityAsserter.AssertResultSetsHaveSameMetaData(SqlString expectedCommand, SqlString actualCommand)
at tSQLtCLR.StoredProcedures.AssertResultSetsHaveSameMetaData(SqlString expectedCommand, SqlString actualCommand)
.
Guru, I have not used this testing framework before, but I can validate that I am getting the same error when the metadata is not the same. This is executing on sql 2008 r2 as well.
When the metadata is the same, no error is thrown.
The guide does say that an error will be raised when the schema does not match, but I would expect the message to have information about what the differences were.
I would be happy to contribute to this project to get it working.
Mark
Pingback: Unit Testing Databases with tSQLt Part 3 – testing table constraints
Pingback: Unit Testing Databases with tSQLt Part 1 – Installation and Setup