Running unit tests that use Microsoft Fakes on Team Build

As you may know I worked on TFS Branch Tool which is one of the ALM Rangers solutions. As usual we are dogfooding latest technology and at some point our builds started failing. We tried to investigate cause and found that product team deployed latest VS 2013 bits into golden image of the agent. We identified that some of the tests that use Microsoft Fakes are failing on hosted build. Don’t be surprised that everything was fine on developer’s computer. So, business as usual.

As it often happens in developer’s life finding of the root cause usually takes 90% of time that needed for solving an issue. Symptoms were very strange – failing unit tests behaved same way like Fakes aren’t running at all. In our case we tested the code that uses Team Foundation Client OM and we had shims to avoid connection to real Team Foundation Server. So, tests are failing because code under test is trying to set up connection to real server.

To narrow down the problem I made few tests proving that Fakes are working on hosted team build if I shimming System.DateTime for example. Then I’ve created fresh new test project and put tests of Team Foundation Client here. Obviously, it working fine. Then it took just few minutes to find a difference between initial project and new one.

Here what I found. Historically Branch Tool was designed using Visual Studio 2012 and Team Foundation Server 2012 object model. Thus, we had references to v. 11 of Microsoft.TeamFoundation.* assemblies. For some reason all references had “Specific Version” option set to “False”. That would allow IDE to use newer version of that assembly if found on the computer. In the project files this looks like:

<ReferenceInclude=Microsoft.TeamFoundation, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL>
  <HintPath>..\..\..\..\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.dll</HintPath>

Reference resolution works pretty consistent between Visual Studio and Team Build but not for the Fakes. It appears that Fakes engine resolves references different way when executing via Team Build. It ignoring value of the “Specific Version” option and always considering it as the true.

We getting into the trouble as soon as we have newer version of Microsoft.TeamFoundation assembly on the computer. Code under test is compiled with reference to v. 12 of the assembly. Fakes framework is ignoring attempt to load of Team Foundation object model types as it expects v. 11. As result, all shims aren’t working at all.

Resolution is very simple – set “Specific Version” option to “True” and use v. 11 assembly explicitly or change reverence to v. 12 assembly if you need fresh Team Foundation object model.

Announcing Visual Studio and Team Foundation Server 2013 RTM Availability

I am happy to share news from Chuck. He just announced product availability in Visual Studio ALM and Team Foundation Server Blog:

Visual Studio 2013 has been released to the web!

Download Visual Studio 2013

Save the date for Visual Studio 2013 Launch on Nov 13th

– Read the release announcements on Soma’s blog (for VS 2013 RTM) and Blogging Windows (for Windows 8.1)

This release has been an amazing ride. While adopting agile development processes across the entire developer division, we have constantly been adding value to Visual Studio and Team Foundation Server 2012 -all while planning and working on a new version of Visual Studio -2013. For Application Lifecycle Management, I have been grouping our efforts into 3 large loosely defined groups of features:

Quality enablement

Quality Enablement is ensuring application quality is pushed upstream so issues aren’t found late in the development cycle and striking the balance between agility and quality to delivering continuous value with software. Contributing to this goal, the diagnostics team has been sharing best practices on this and other MSDN blogs, about the many enhancements to the debugger and profiling tools in Visual Studio. To help you find all the links please start with the index here: Diagnostics Investments in Visual Studio 2013. In addition to the diagnostic tools we have been making large strides in the areas of Testing such as Coded UI testing for Windows Applications, Unit Testing for Windows Applications, Cloud based Load Testing and significant improvements in Web based Test management and execution.


Agile Planning

Visual Studio and Team Foundation Server agile processes, practices, and tools, are designed to help businesses deliver software faster, with continuous value, and minimal risk. By using the suite of tools in Visual Studio Team Foundation Server 2013, and combining those tools with Visual Studio Team Foundation Server, you can apply proven practices to manage your application’s lifecycle, from understanding customer needs through code design and implementation to deployment. You can use the instrumentation in these tools to trace requirements to checked-in code, builds and test results. These practices can help your team create software that is valued by your customers and that is faster and more reliable.  The features we offer to enable Agile Planning goes on and on but to call out a few: Built-in task board, Backlog management, Capacity planning, Issue and bug tracking, Team Rooms, Storyboarding with Microsoft PowerPoint, Integrated feedback tool and process, Discuss Code Changes, Agile Portfolio Management and more.


Developer Operations

Visual Studio 2013 expands agile ALM practices to operations as a natural progression and emphasizes integrating the development and operations functions to reduce cycle time and ensure continuous delivery. With the release of Visual Studio 2013 we have done this in a couple of areas such as the release of the Microsoft Monitoring Agent, the integration of Intellitrace with System Center, enhancing Intellitrace to work in production environments and the inclusion of InRelease product into the Visual Studio suite of tools. Microsoft Monitoring Agent monitors computer infrastructure and application health. It collects diagnostic data, such as performance metrics, event logs, and traces. Microsoft Monitoring Agent can be used as a standalone tool or together with System Center Operations Manager. When monitoring .NET applications, you can direct the agent to save application traces in an IntelliTrace log format. InRelease is a Continuous Delivery solution for .NET teams that automates the release process from Visual Studio Team Foundation Server (TFS) up to production for faster and simpler deliveries. With pre-defined release paths, InRelease automatically deploys your application as a whole to multiple environments. Based on a business-approval workflow, InRelease improves coordination and communication between development, operations and quality assurance to make release cycles repeatable, visible, and more efficient.

I hope you enjoy Visual Studio 2013, thank you for all the words of encouragement, feedback and suggestions that has helped shape Visual Studio 2013- You really are an important part of the development process and the ALM features would not look like they do without your involvement. We look forward to hearing from your feedback / ideas so please add your suggestions to UserVoice or vote up an existing suggestion. Use Connect to log bugs, and Forums for Q&A. You can also contact Product Support for any issues in production. If you are just getting started be sure and check out: Chuck’s Top ten reasons to try out Visual Studio 2013. If you haven’t already downloaded the Visual Studio 2013 Preview or RC releases, when you first launch Visual Studio 2013 you’ll be invited to sign in to Visual Studio with a Microsoft Account. These New Start settings and start page video experience are my two favorite of the UI improvements. The new Start settings enhancements is where Visual studio will remember my settings across multiple computers INCLUDING ALL MY TEAM FOUNDATION SERVICE accounts I am a member of-YEAH! For more information on this check out Signing in to Visual Studio or Welcome. Sign in to Visual Studio. If you choose to not sign in, all the traditions ways to license your IDE still work, but features associated with signing in, like Synchronized Settings will not work.


While this post is no way meant to be a FAQ one of the questions I have seen a couple of times is around the compatibility of the Visual Studio and Team Foundation versions. If you are going to be running a mixed environment of versions (like most of us) please bookmark this page:

Compatibility between Team Foundation clients and Team Foundation Server

For other enhancements in the Visual Studio and Team Foundation Server 2013 release please make sure and check out this source of great information:

Enhanced Visual Studio 2013 editor features

What’s New in Visual Studio 2013

Productivity Tips for Visual Studio

System requirements and platform compatibility

Brian Harry’s Blog

Somasegar’s blog

Visual Studio Blog

.NET Framework Blog

Visual C++ Team Blog

Team Foundation Service Updates

Visual Studio LightSwitch Team Blog

.NET Web Development and Tools Blog

Windows App Builder Blog

Apps for Office and SharePoint Blog

Steve “Guggs” Guggenheimer’s Blog

Scott Hanselman’s Blog

Scott Guthrie’s Blog

Hello world!

Basically, I’m blogging in Russian for more than 3 years already. That was always dilemma for me which language to use for blogging. Historically it was Russian as I want to support idea of reading technical information in native language. I know for sure that many people in our technology in Russia still prefer Russian.

At the same time I often feel not comfortable as I have interesting and rare information to share with broader audience. So, I decided to open English blog as well…

Let’s see how it goes… Please feel free to blame me as well as provide valuable feedback. 🙂