tfs 2012 failed to run test case: Error calling Initialization method for test class

712 views Asked by At

Recently we found our integration test failed unexpected with following exception:

We even remeber that we have changed nothing to TFS BDT workflow and test case.

Error exception:

Error calling Initialization method for test class UITestDemo.UITestDemo01: Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException: To run tests that interact with the desktop, you must set up the test agent to run as an interactive process. For more information, see "How to: Set Up Your Test Agent to Run Tests That Interact with the Desktop" (http://go.microsoft.com/fwlink/?LinkId=255012) If you are running the tests as part of your team build, you must also set up the build agent to run as an interactive process. For more information, see "How to: Configure and Run Scheduled Tests After Building Your Application" (http://go.microsoft.com/fwlink/?LinkId=254735)

Error Stack Trace:

Microsoft.VisualStudio.TestTools.UITesting.Playback.Initialize() Microsoft.VisualStudio.TestTools.UITesting.CodedUITestExtensionExecution.BeforeTestInitialize(Object sender, BeforeTestInitializeEventArgs e) Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestExecution.RaiseBeforeTestInitialize(BeforeTestInitializeEventArgs args) Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestExecuter.RunInitializeMethod()

We have no idea how to fix it.

1

There are 1 answers

0
Amitabha On

After investigation, we found that test is running by account: "computerName$" on environment, not the specified account in test controller settings.

<?xml version="1.0" encoding="utf-8"?>
<SystemInformation>
  <ComputerName>ComputerName</ComputerName>
  <UserName>ComputerName$</UserName>
  <UserDomainName>WORKGROUP</UserDomainName>
  <OSInfo>
    <OSName>Microsoft Windows Server 2008 R2 Enterprise </OSName>
    <OSVersion>Microsoft Windows NT 6.1.7601 Service Pack 1</OSVersion>
    <SystemDirectory>C:\Windows\system32</SystemDirectory>
    <SystemLocale>English (United States)</SystemLocale>
    <UserLocale>English (United States)</UserLocale>
  </OSInfo>
  <ProcessorInfo>
    <Processor0>
      <ProcessorName>Intel(R) Xeon(R) CPU E5-2690 v2 @ 3.00GHz</ProcessorName>
      <ProcessorFamily>Intel64 Family 6 Model 62 Stepping 4</ProcessorFamily>
      <ProcessorSpeed>2999</ProcessorSpeed>
    </Processor0>
    <Error>NoError</Error>
  </ProcessorInfo>
  <MemoryInfo>
    <TotalPhysicalMemory>4945</TotalPhysicalMemory>
    <AvailablePhysicalMemory>1541</AvailablePhysicalMemory>
    <MemoryLoad>68</MemoryLoad>
    <TotalVirtualMemory>2047</TotalVirtualMemory>
    <AvailableVirtualMemory>1432</AvailableVirtualMemory>
    <Error>NoError</Error>
  </MemoryInfo>
  <ScreenInfo>
    <ScreenHeight>768</ScreenHeight>
    <ScreenWidth>1024</ScreenWidth>
    <BitsPerPixel>32</BitsPerPixel>
  </ScreenInfo>
  <IEInfo>
    <IEVersion>11.0.9600.16428</IEVersion>
    <Error>NoError</Error>
  </IEInfo>
</SystemInformation>

Solution: We open the using test settings in MTM test settings manager. And recheck each environment should run test on correct role.

Then retest run pass.