Database unit testing is now available for SSDT
Posted
by jamiet
on SQL Blog
See other posts from SQL Blog
or by jamiet
Published on Fri, 14 Dec 2012 12:47:47 GMT
Indexed on
2012/12/14
17:12 UTC
Read the original article
Hit count: 307
SSDT
|Unit Testing
Good news was announced yesterday for those that are using SSDT and want to write unit tests, unit testing functionality is now available. The announcement was made on the SSDT team blog in post Available Today: SSDT—December 2012. Here are a few thoughts about this news.
Firstly, there seems to be a general impression that database unit testing was not previously available for SSDT – that’s not entirely true. Database unit testing was most recently delivered in Visual Studio 2010 and any database unit tests written therein work perfectly well against SQL Server databases created using SSDT (why wouldn’t they – its just a database after all). In other words, if you’re running SSDT inside Visual Studio 2010 then you could carry on freely writing database unit tests; some of the tight integration between the two (e.g. right-click on an object in SQL Server Object Explorer and choose to create a unit test) was not there – but I’ve never found that to be a problem. I am currently working on a project that uses SSDT for database development and have been happily running VS2010 database unit tests for a few months now.
All that being said, delivery of database unit testing for SSDT is now with us and that is good news, not least because we now have the ability to create unit tests in VS2012. We also get tight integration with SSDT itself, the like of which I mentioned above. Having now had a look at the new features I was delighted to find that one of my big complaints about database unit testing has been solved. As I reported here on Connect a refactor operation would cause unit test code to get completely mangled. See here the before and after from such an operation:
SELECT *
FROM bi.ProcessMessageLog pml
INNER JOIN bi.[LogMessageType] lmt
ON pml.[LogMessageTypeId] = lmt.[LogMessageTypeId]
WHERE pml.[LogMessage] = 'Ski[LogMessageTypeName]of message: IApplicationCanceled'
AND lmt.[LogMessageType] = 'Warning';
which is obviously not ideal. Thankfully that seems to have been solved with this latest release.
One disappointment about this new release is that the process for running tests as part of a CI build has not changed from the horrendously complicated process required previously. Check out my blog post Setting up database unit testing as part of a Continuous Integration build process [VS2010 DB Tools - Datadude] for instructions on how to do it. In that blog post I describe it as “fiddly” – I was being kind when I said that!
© SQL Blog or respective owner