DbUp and tSQLt

78 views
Skip to first unread message

Andrew Johns

unread,
Oct 25, 2018, 9:28:24 PM10/25/18
to DbUp Discuss
Hi,

Wondering if anyone has had any experience of DbUp and tSQLt and whether they can sanity check what I'm thinking about at 2am in the morning.

I've previously created a DbUp project for my Db schema, with additional seed data for test purposes. I'm about ready to add an automated step to teamcity to deploy this db to a test environment.

I'm now looking at setting up another step in teamcity to run some sort of validation to prove the few stored procedures and functions present are returning expected seed data. I initially thought I might just run a sqlcmd to call the SPs with params and then compare the outputs to a csv or similar. I've also considered using something like specflow to write tests against the db.

Having then actually googled for possbible options, I've come across tSQLt, which could provide a good base for writing these tests, but in addition, having installed via Redgate tools I've been demoing, it has also generated additional SQLCop tests which could be very useful.

My plan:

Keep the tSQLt framework and tests in a separate dbUp project, so that I can run the main deploy project on all environments, and only deploy the tSQLt framework in test environments. (Arguably the seed data should also be moved into this project as well, but the intention was to use that seed data for other tests such as UI regression testing)

Given I have already generated the framework on a local db server, I'm thinking I need to export everything into scripts to be added to a new DbUp project, then automate this deployment to the same DB as my main DB project when in a test environment.

Does this sound sensible? Anyone done something similar?

Darrell Tunnell

unread,
Oct 26, 2018, 4:25:13 AM10/26/18
to dbup-d...@googlegroups.com
I have not looked at tsqlt test framework, but if all you want to do is execute a sproc and verify the results, have you looked at ApprovalTests as I think that fits in with your initial line of thinking before you googled - it seems simpler. However putting that choice aside, and assuming you do need to run some additional provisioning on the database to support your tests, then yes, putting these scripts in a seperate dbup project for provisioning the test framework itself to the test server sounds ok to me..

--
You received this message because you are subscribed to the Google Groups "DbUp Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dbup-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Johns

unread,
Oct 26, 2018, 10:38:45 AM10/26/18
to DbUp Discuss
ApprovalTests may be the answer, thanks. I also see the value in converting some of my older unit tests to use it...sigh...the never-ending cycle of updating your code base as you find new ways to do things. Must resist!
Reply all
Reply to author
Forward
0 new messages