Unit Test filtering for TFS builds using Test Explorer in VS 2012

One of the major new features in Visual Studio 2012 is the Text Explorer tool window, which consolidates 2010’s Test View and Test Results windows and adds support for using different testing frameworks together in one place. There are definitely some positive aspects to Test Explorer in comparison to its predecessors, but as a completely new piece of functionality it unfortunately left out some key features that were previously available.

One of the places it fell short was in filtering of tests to enable running a specific subset of the tests in your solution, especially when working with a set of tests set up for TFS’s Team Build. When working with small sets of tests it could be a minor annoyance, but working with hundreds or thousands of tests made it basically unusable. Thanks to Visual Studio’s new release model of frequent updates, these shortcomings are already starting to be addressed with November’s Update 1.

The preferred method of specifying tests to run with builds in TFS is by using attributes on test methods, specifically the Priority and TestCategory attributes. VS2010’s Test View displays a configurable grid listing all available tests in the open solution.
image

Continue reading

Presentation Materials for New England Code Camp 17

Thanks to everyone for coming!

What’s new in Visual Studio 11: Slides | Code
Check the slides for the list of all of the new Visual Studio features we looked at.

Easy Async in .NET 4.5: Slides | Code (for VS11 Beta)
The only code demo we didn’t get to look at can be found in the AddingAsync page, which shows a progression of converting a more complex 2 step data loading process from fully synchronous to fully asynchronous including cancellation and exception handling.

My favorite new features in VS11 Beta

After having a week to work with the new Visual Studio Beta, I’m already missing some of the new features when I need to jump back over to 2010. Here are some of my favorites, in no particular order.

Quick Find

image
This is a frequently highlighted new feature, and I’ve definitely found it useful already as a quick shortcut for getting to almost any function in the IDE. My favorite part of it is that it’s so keyboard focused and allows me to skip reaching for the mouse to do things that I would normally just dig into a menu for. As a longtime SlickRun user, the keyboard shortcut to activate it also feels really natural (SlickRun uses Win+Q, Quick Find is Ctrl+Q) and the fast auto-complete search feels similar too.

Incremental Search feels right again

image
Although much of the new functionality was available previously through the Power Tools, a few of the things that got pulled in finally got that extra polish that makes them just feel right. One of the first Power Tools that I had turned off was the new unified Find box that took over a bunch of different functions and keyboard shortcuts. The big problem I had was the way it handled Ctrl+I incremental search. I use this so frequently that it’s a reflex and there were a few hiccups in keyboard focus that caused me to have to stop and figure out how to get back to the state I wanted to be in in the editor. Now, in the beta, this experience has been smoothed out, and the only noticeable difference from the old Ctrl-I functionality are the new visual cues: the box up top showing what I’ve typed, the extra highlighting of all matches in the current window, but the keyboard experience feels the same, and responds just like I expect.

Navigate To (Ctrl+,)

image
One of the things I miss most when working in a bare instance of Visual Studio that doesn’t have my two favorite extensions installed (CodeRush and ReSharper) is quick keyboard navigation to any type in my solution. The new Navigate To window provides a similar (though not identical) experience, with a search while typing listing of types and members, including camel casing caps shorthand, and instant navigation to the selected item.

Out of process solution load and build

This one is pretty obvious, but I know a lot of work went into this and it’s going to be such a dramatic time and frustration saver. Finally those extra cores are getting used on the big workloads.

TFS Local Workspaces

So many cool things about this, and I’ve only scratched the surface so far, but just the way this has been worked into the UI is really impressive. Like if you need to switch back and forth between Local and Server workspaces, there’s one button to click. Doing a Compare to the workspace version of the file just works the same, but doesn’t need to talk to the server at all, so is much faster. No more worrying about accidentally changing a file from outside VS and getting out of sync – now VS is watching and will pick up the change for you. Just all around a well thought out experience and hits a lot of the big annoyances people have with using TFS source control.

New Diff tool

Finally, the Visual Source Safe compare window is gone. A lot here is similar to other diff tools that you could previously point TFS to for your comparisons, but being built in not only skips that extra configuration, but also gives you the full VS editor. Editing a file right in the compare window with full syntax highlighting, Intellisense, and even instant updates of the compare state feels like magic after so much time spent with the old one. The UI isn’t the only part that’s changed either. TFS auto-merging is much improved too and should cut down dramatically on the number of times you even see the merge window.

Using Fakes for easy unit test stubs and shims in VS11

There are a lot of different ways to do mocking in .NET unit tests, from writing your own mock interface implementations to fully built out commercial frameworks like TypeMock. The Moles Isolation framework from Microsoft Research offered some intriguing possibilities but as a research project has never had the same level of support as a full product. Now the Moles concepts and much of the usage syntax have shown up in the Visual Studio 11 beta renamed as Fakes.

The first step in using Fakes is to add a reference to the new Microsoft.QualityTools.Testing.Fakes assembly in your unit test project. Continue reading