Search code examples
visual-studiotestingnunittsqlt

Exposing tSQLt as NUnit tests


Is there any way to expose tSQLt tests inside Visual Studio, in a similar way to NUnit?

Even better, so all the tests in a solution can be run using Resharper

... I'm aware of Red Gates SQL Test product, but it only seems to target SSMS


Solution

  • Yes this is actually very easy, but does require writing some plumbing code. The TestClasses, Tests and TestResults are all available in tSQLt. We have simply written a t4 template that wraps our tSQLt tests and we use the template to generate the nunit tests. Our tSQLt workflow is all within our Visual Studio projects and we use FluentMigrator to do our database migrations.

    I have posted a tSQLt demo workflow solution on github (tsqlt-demo-workflow) if you are interested. This workflow is similar to the one that we have been working with.

    Hope this helps.