If you write code to SQL Server then you might be interested in this: I have written a tSQLt tdd training course which has helped over 500 people learn both tSQLt and how to apply TDD practices to their SQL Server T-SQL development, you can join the course at https://courses.agilesql.club.

Why is my tSQLt test not running?

I wrote a test earlier and forgot one of the two cardinal rules about tSQLt so I was running my test suite and the test did not run, I re-deployed and it still didn’t run so I thought I would create this handy list of things to check that mean that even when the tests exist in the database they do not run:

  • Are the tests in a schema that has the tSQLt test class extended property?
  • Does the name of the test start with the word “test”? If it doesn’t then it will not actually run

Test schema extended property

You need to create a schema which is basically the test class:

CREATE SCHEMA [thingy_a_bob]
go
EXECUTE sp_addextendedproperty
@name = N’tSQLt.TestClass’
, @value = 1
, @level0type = N’SCHEMA’
, @level0name = N’thingy_a_bob’;
go

If the lovel0name does not match the name of the schema then it won’t actually apply to it so make sure that it is correct.

test name

The test MUST begin with the word test so this is valid:

create procedure [thingy_a_bob].[test this does something cool] as ...

but this is invalid:

create procedure [thingy_a_bob].[this does something cool] as ...

If this doesn’t help?

If you have checked both of these things then go back to making sure that the test is actually deployed!

Subscribe

* indicates required

Please select all the ways you would like to hear from Agile Sql Club:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.