locked
MSTest Coded UI Test Could not load file or assembly Microsoft.VisualStudio.TestTools.UITesting RRS feed

  • Question

  • Hi,

    I have created some Coded UI Tests in a Test Project using Visual Studio Premium 2013 (Version 12.0.30723.00 Update 3).

    Those Coded UI tests run just fine when I run them from inside Visual Studio (Go to Test Explorer and hit Run).

    However If I try to run them using MSTest.exe or VSTest.Console.exe I am not able to.

    When I run the tests using MSTest I get the following error:
    Loading CodedUITests.dll...
    CodedUITests.dll
    Unable to load the test container 'CodedUITests.dll' or one of its dependencies.
     Error details: System.IO.FileNotFoundException: Could not load file or assembly
     'Microsoft.VisualStudio.TestTools.UITesting, Version=12.0.0.0, Culture=neutral,
     PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot
    find the file specified.

    If I run them using VSTest.Console.exe I get the following error:

    Starting test execution, please wait...
    Warning: Unable to load types from the test source 'C:\PathToTestProject\bin\Debug\CodedUITests.dll'.
    Some or all of the tests in this source may not be discovered. If you are running unit tests for Windows Store apps and referencing custom WinMD type then please visit http://go.microsoft.com/fwlink/?LinkId=238340 for more info. Error details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestTools.UITesting, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified..

    Warning: No test is available in CodedUITests.dll. Make sure that installed test
     discoverers & executors, platform & framework version settings are appropriate
    and try again.

    I try to find this issue online and was not able to find anyone with a similar problem.I am not sure if there is something corrupted with my VS instalation that may be causing this problem.

    Could someone help me with this?

    Thanks!


    Brazeta

    PS: This path "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies" exists in the machine where I have VS and where I am executing the MSTest command. This path contains all the Microsoft test assemblies, including "Microsoft.VisualStudio.TestTools.UITesting.dll"

    Monday, April 13, 2015 3:29 PM

Answers

  • Hi Brazeta,

    >> Using the Developer Command Prompt for VS2012 if I navigate the the "Debug" folder of my project none of the following scripts will work:

    It seems that it was caused by the different versions of the Developer Command Prompt. In my option, if you create a project in Visual Studio 2013, I am afraid that you need to use the Developer Command Prompt for VS2013 instead of using for VS2012. I will recommend you try to use the Developer Command Prompt for VS2013.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by José Brazeta Tuesday, April 14, 2015 9:40 AM
    Tuesday, April 14, 2015 9:00 AM

All replies

  • Hi Brazeta,

    >> Those Coded UI tests run just fine when I run them from inside Visual Studio (Go to Test Explorer and hit Run). However If I try to run them using MSTest.exe or VSTest.Console.exe I am not able to.

    Do you mean that Coded UI tests run fine in VS, but failed with MSTest? Before you run with MSTest, have you changed the Coded UI project? Did you change the project after you run in vs?
    I made a simple test, and I could work both correctly in vs in mstest. Could you share us the MSTest command?

    Have you set the platform (x64 or x32) in your test? If so, I think you could refer the link below:

    # running mstest from command line against visual studio 2012 native c++ tests
    http://stackoverflow.com/questions/15086380/running-mstest-from-command-line-against-visual-studio-2012-native-c-tests

    Was your UITesting in another dll? If so, you could refer the link below:

    # Visual stuido dlls are impacting the execution of Coded UI Test https://social.msdn.microsoft.com/Forums/en-US/e74f4a8a-5a28-453f-943d-1c7cd5665444/visual-stuido-dlls-are-impacting-the-execution-of-coded-ui-test?forum=vsautotest

    It would be helpful if you could share us more information about your project.

    Hope it will help.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 14, 2015 3:38 AM
  • Hi Edward

    >> Do you mean that Coded UI tests run fine in VS, but failed with MSTest?

    Yes, that is exactly the case!

    >>Before you run with MSTest, have you changed the Coded UI project?

    No. In Visual Studio I can run the Coded UITests by going to Text Explorer and click the run button. Without changing anything else, if I try to run them in using mstest or vstest.console I am not able to

    >>Did you change the project after you run in vs?

    No. The project did not change at all

    >> Could you share us the MSTest command?

    I run the commands in "Developer Command Prompt fro VS2012". the commands are:

    MSTEST:

    mstest /testcontainer:CodedUITests.dll

    Microsoft (R) Test Execution Command Line Tool Version 11.0.50727.1
    Copyright (c) Microsoft Corporation. All rights reserved.

    Loading CodedUITests.dll...
    CodedUITests.dll
    Unable to load the test container 'CodedUITests.dll' or one of its dependencies.
     Error details: System.IO.FileNotFoundException: Could not load file or assembly
     'Microsoft.VisualStudio.TestTools.UITesting, Version=12.0.0.0, Culture=neutral,
     PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannotfind the file specified.

    VSTEST.CONSOLE

    vstest.console CodedUITests.dll

    Microsoft (R) Test Execution Command Line Tool Version 11.0.60315.1
    Copyright (c) Microsoft Corporation.  All rights reserved.

    Starting test execution, please wait...
    Warning: Unable to load types from the test source 'C:\MyProjects\CodedUITests\bin\Debug\CodedUITests.dll'.
    Some or all of the tests in this source may not be discovered.
    If you are running unit tests for Windows Store apps and referencing custom WinMD type then please visit
    http://go.microsoft.com/fwlink/?LinkId=238340 for more info.
    Error details: System.IO.FileNotFoundException:
    Could not load file or assembly 'Microsoft.VisualStudio.TestTools.UITesting,
    Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
    The system cannot find the file specified..

    Warning: No test is available in CodedUITests.dll. Make sure that installed test
     discoverers & executors, platform & framework version settings are appropriate
    and try again.


    Information: Additionally, you can try specifying '/UseVsixExtensions' command i
    f the test discoverer & executor is installed on the machine as vsix extensions
    and your installation supports vsix extensions. Example: vstest.console.exe myTe
    sts.dll /UseVsixExtensions:true

    >>Have you set the platform (x64 or x32) in your test? If so, I think you could refer the link below:

    The selected platform is AnyCPU

    >>Was your UITesting in another dll? If so, you could refer the link below:

    The tests are all in the CodedUITests dll. All tests were created inside a test project (called CodedUITests, they run ok if I execute them in VS but the show the abouve error if I run them using the Developer Command Prompt for VS2012).

    I didn´t mention this before but I DO NOT have test controller and test agents installed in my PC! I just have Visual Studio installed (not 100% sure if I need the agent to run the UI Tests in the same PC where I have VS installed).

    I hope this information may be usefull,

    Best Regards,

    José Brazeta

    PS:
    I just try to create a very simple UI Test in another PC where I have Visual Studio 2013 Ultimate (Versio12.0.30723.00 Update 3).
    Using VS I created a new Solution with just 1 project (Coded UI Test Project) and recorded a very simple test (on IE and at the google page search for Coded UI Test and hit the search button).
    After compiling the Coded UI Test project in VS I can see the test in Test Explorer and If I run the test it all goes ok.
    Using the Developer Command Prompt for VS2012 if I navigate the the "Debug" folder of my project none of the following scripts will work:

    mstest /testcontainer:CodedUITestProject1.dll
    vstest.console CodedUITestProject1.dll
    I get the same error that I show in the bigining of this post.




    Tuesday, April 14, 2015 8:06 AM
  • Hi Brazeta,

    >> Using the Developer Command Prompt for VS2012 if I navigate the the "Debug" folder of my project none of the following scripts will work:

    It seems that it was caused by the different versions of the Developer Command Prompt. In my option, if you create a project in Visual Studio 2013, I am afraid that you need to use the Developer Command Prompt for VS2013 instead of using for VS2012. I will recommend you try to use the Developer Command Prompt for VS2013.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by José Brazeta Tuesday, April 14, 2015 9:40 AM
    Tuesday, April 14, 2015 9:00 AM
  • Hi Edward

    First of all thank you so much for your answer, it was a life saver :)

    It was such a simple problem but I was not seeing the entire picture.

    The solution, like you suggested , was to run the tests using the "Developer Command Prompt for VS2013". Now the question that anyone seeing this post can ask is why didn´t I use the "Developer Command Prompt for VS2013" in the first place??

    The answer is because I didn´t know it existed.

    I have VS2012 and VS2013 installed in both machines.

    Both in Windows 7 and Windows 8, after you installed Visual Studio 2013, if you search (in the start menu) by "Developer Command Prompt" you will have only 1 result : "Developer Command Prompt for VS 2012". So I automatically assumed that this was the correct one.

    After you suggested the use of "Developer Command Prompt for VS 2013" I search for in the the start menu but no result was displayed! So I google it and find this on stackoverflow:
    http://stackoverflow.com/questions/21476588/where-is-developer-command-prompt-for-vs2013

    The answer for "WiredPrairie" was the one that helped me. The shortcut for "Developer Command Prompt for VS2013" is under "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts" and is not present in the start menu folder, so if you search for it it will not be displayed!
    All you have to do is copy it to "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2013"

    Now, if I search for "Developer Command Prompt" I have the search results for VS2012 and VS 2013

    After run the exact same commands in the "Developer Command Prompt for VS2013" the UI tests started working as expected!

    Like I said before this was clearly my mistake (I should know the existence for the VS2013 command prompt).
    But under a usability perspective the fact that this command prompt is not displayed as a search result is extremely misleading. If the two results were displayed (command prompts for vs2012 and vs2013) it would be unlikely that a user would choose the wrong one in this situation.

    Best Regards,

    José Brazeta


    Tuesday, April 14, 2015 9:40 AM
  • Hi Brazeta,

    Thanks for your sharing us the solution here, so it would be helpful for other members who get the same issue.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 15, 2015 3:32 AM