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.

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.
- In the xaml build template, navigate to the section on Run Visual Studio Test Runner for Test Sources
- 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()

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.