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: 271

Filed under:
|

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:

20110516 Refacoring preview changes

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!

@Jamiet

© SQL Blog or respective owner

Related posts about SSDT

  • SSDT - What's in a name?

    as seen on SQL Blog - Search for 'SQL Blog'
    SQL Server Data Tools (SSDT) recently got released as part of SQL Server 2012 and depending on who you believe it can be described as either: a suite of tools for building SQL Server database solutions or a suite of tools for building SQL Server database, Integration Services, Analysis… >>> More

  • Redistribution of sqlpackage.exe [SSDT]

    as seen on SQL Blog - Search for 'SQL Blog'
    This is a short note for anyone that may be interested in redistributing sqlpackage.exe. If this isn’t you then no need to keep reading. Ostensibly this is here for anyone that bingles for this information. sqlpackage.exe is a command-line that ships with SQL Server Development Tools (SSDT) in SQL… >>> More

  • Smart defaults [SSDT]

    as seen on SQL Blog - Search for 'SQL Blog'
    I’ve just discovered a new, somewhat hidden, feature in SSDT that I didn’t know about and figured it would be worth highlighting here because I’ll bet not many others know it either; the feature is called Smart Defaults. It gets around the problem of adding a NOT NULLable column to an existing table… >>> More

  • Smart defaults [SSDT]

    as seen on SQL Blog - Search for 'SQL Blog'
    I’ve just discovered a new, somewhat hidden, feature in SSDT that I didn’t know about and figured it would be worth highlighting here because I’ll bet not many others know it either; the feature is called Smart Defaults. It gets around the problem of adding a NOT NULLable column to an existing table… >>> More

  • Want a headless build server for SSDT without installing Visual Studio? You’re out of luck!

    as seen on SQL Blog - Search for 'SQL Blog'
    An issue that regularly seems to rear its head on my travels is that of headless build servers for SSDT. What does that mean exactly? Let me give you my interpretation of it. A SQL Server Data Tools (SSDT) project incorporates a build process that will basically parse all of the files within the… >>> More

Related posts about Unit Testing