VS Unit Test Progress Indication

If you do unit tests (and if not, you should), chance is once in a while a test will, (perhaps by design), take a long time to complete.

Visual Studio’s Unit Testing Framework frontend gives an indication of progress between different tests, but not what the running test is doing (this seems to be the case even for VS2012).

In some cases, for example, when doing a sanity check on generated DB tables, it would be more helpful to know what the current test is doing and perhaps when it will finish.

I’ve had this situation a few times and the solution, although not very elegant, seems to be to spawn your own UI thread that does the job. I haven’t been able to find some ready code to do the job, so I did my own.

As a minimum, you need add a reference to these two assemblies in your test project:

  • System.Windows.Forms
  • System.Drawing

This is because they are required in order to build our UI. With those in place, one just needs to instantiate the UI in a new thread (in Single Threaded Apartment mode). From then on, it’s a matter of updating the form as desired (but keeping in mind we’re doing this across threads, so SetControlPropertyThreadSafe() is required).

The code for all of this can be found on GithHub (of course). Enjoy!

From Web to Desktop

These last few weeks have been quite a change for me. As you may know, I have changed workplace and consequently, my tools of the trade at work. After years working with Web technologies (PHP, Javascript) and Linux servers, I have now switched to C# mainly on the Desktop in an MS-dominated environment. There are challenges as well as advantages, just as there were before. As such I can’t rate this transition but I must admit I do miss the familiarity I had acquired. Still, this is a great opportunity for new experiences, which is what I was seeking in making my move.

So, how’s it been so far? Well, I found C# very easy to work with – the second script I wrote involved executing C# expressions on the fly (together with caching and code preprocessing). And guess what? It worked on my second run! Yeah, I’m that good. 😀 Seriously though, C# is a very modern language with a strong set of pre-built libraries and functionality. This means that a new developer only needs to be familiar with the syntax and know how to look things up in the docs… easy!

As part of my new job, I currently have to work a lot with SQL (MS and Oracle). Admittedly, this is not an area I like but on the bright side I get the opportunity to fill this knowledge gap. Oh, and I’m currently using this awesome tool from MS known as BIDS/SSIS – it basically makes database migration really easy.