bryanpjohnston

A blog by someone with not much to say.

Month: May, 2013

TFS 2012 Build Fails When Unit Testing Multiple Platforms

For certain projects, I want to build both x86 and x64 platforms. I also would like to run unit tests for each platform. When you specify your unit tests, you must also specify the platform on which they should run.

tests

The problem is, by default, TFS tries to run each test set on each platform that you built. In my case, that means it tries to run the tests across platforms.

Project Configurations

Tests That Get Run

Release | x86

X86 (passes)

X64 (fails)

Release | x64

X86 (fails)

X64 (passes)

Actually, to be a bit more clear, the tests don’t fail. When an x86 test tries to run on the x64 platform build (and vice-versa), it generates the following build error:

None of the provided test containers match the Platform Architecture and .Net Framework settings for the test run. Platform: X86 .Net Framework: Framework45. Go to http://go.microsoft.com/?link for more details on managing these settings.
None of the provided test containers match the Platform Architecture and .Net Framework settings for the test run. Platform: X64 .Net Framework: Framework45. Go to http://go.microsoft.com/?link for more details on managing these settings.

To rectify the issue, you may modify the default xaml template that runs the build (or a custom template that you may have derived from the default TFS2012 template) so that TFS only attempts to run unit tests for the appropriate platform.

  1. In the xaml build template, navigate to the section on Run Visual Studio Test Runner for Test Sources
  2. Modify the condition of the section titled If Visual Studio Test Platform Test Assemblies Found to compare the platform of the unit test set to the platform of what was built (see screenshot):

    agileTestPlatformAssembly.ExecutionPlatform.ToString().ToLower() = platformConfiguration.Platform.ToString().ToLower()

cibuild

Now my x86 unit tests are only run on the x86 build and the x64 unit tests are only run on the x64 build. And more importantly, no build errors get generated.

Advertisements

Unit Tests Don’t Run After Installing Visual Studio 2012 Update 2

Shortly after our team installed VS2012 Update 2, I noticed our automated builds failed when executing unit tests.

TF900546: An unexpected error occurred while running the RunTests activity: ‘Method not found: ‘Void Microsoft.VisualStudio.TestPlatform.Utilities.ClientUtilities.InitializeTestPlatform(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestPlatform, System.String, System.Collections.Generic.List`1<System.String>)’.’.

ciError

These problems didn’t occur when running tests locally. I updated the build machine with VS2012 Update 2 and still no luck. After failing to find any helpful information on the Internet, it hit me: the build machine doesn’t use VS2012 to run the builds. In fact, VS doesn’t need to be installed on the build machine at all (although it can be helpful when troubleshooting other issues).

I downloaded TFS 2012 Update 2 and installed it on the build machine. SUCCESS! No more failures when executing our unit tests on the build machine.