Search code examples
c#testingvisual-studio-2013coded-ui-testsweb-testing

FileNotFoundException when executing CodedUITests locally after build


I am new in VS2013 and C#. I was trying to test the UI of a Webpage with VS CodedUITests and WebTests. This has been done successfully. I have my tests working when I run them manually.

The problem comes when I want to automate this process. Instead of using a Test Agent (I would need a second machine) I wanted to create a Build and run these tests right after a successful build. I created the build and it works fine (I get Build partially succeeded), but the tests do not run because somehow (even after successfully building) it cannot find UITesting reporting this error:

Run MSTest for Test Assemblies
   + d:\a\bin\CodedUITestProject1.dll
   + Unable to load the test container 'd:\a\bin\CodedUITestProject1.dll
     or one of its dependencies. Error details: System.IO.FileNotFoundException:
     Could not load file or assembly 'Microsoft.VisualStudio.TestTools.UITesting,
     Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one
     of its dependencies. The system cannot find the file specified.

I don't have this d:\a\bin path anywhere, so I suppose it is a temporary path for the build. I am not sure that what I am doing is possible or not. All I want is to build my projects and run these UI/Web tests, but maybe this is not the right approach. Any help with this?

UPDATE

This is the project's Local.testsettings:

<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="Local" id="38e7b5f5-3e94-4739-a620-dfb4ddfa9c35" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <Description>These are default test settings for a local test run.</Description>
  <Deployment>
    <DeploymentItem filename="..\CodedUITestProject1\" />
  </Deployment>
  <Execution>
    <TestTypeSpecific>
      <UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
        <AssemblyResolution>
          <TestDirectory useLoadContext="true" />
        </AssemblyResolution>
      </UnitTestRunConfig>
      <WebTestRunConfiguration testTypeId="4e7599fa-5ecb-43e9-a887-cd63cf72d207" runUntilDataExhausted="true">
        <Browser name="Internet Explorer 10.0" MaxConnections="6">
          <Headers>
            <Header name="User-Agent" value="Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)" />
            <Header name="Accept" value="*/*" />
            <Header name="Accept-Language" value="{{$IEAcceptLanguage}}" />
            <Header name="Accept-Encoding" value="GZIP" />
          </Headers>
        </Browser>
      </WebTestRunConfiguration>
    </TestTypeSpecific>
    <AgentRule name="LocalMachineDefaultRole">
    </AgentRule>
  </Execution>
  <Properties>
    <Property name="TestSettingsUIType" value="UnitTest" />
  </Properties>
</TestSettings>

Solution

  • It is necessary to have the same version of Visual Studio on the Build Server. In this case I was compiling and running Coded UI Tests, so I needed, at least, Visual Studio Premium.