locked
Cannot run MSTest on my unit test dll from the command line (VS2013) RRS feed

  • Question

  • I created a test solution (default console project) and added a unit test project with defaults. I then ran the unit test from the VS IDE successfully. However, running the unit test from the command line failed to execute with the following message:

    ...\TestApp\Debug> mstest /testcontainer:unittest1.dll
    Microsoft (R) Test Execution Command Line Tool Version 12.0.21005.1
    Copyright (c) Microsoft Corporation. All rights reserved.

    Loading unittest1.dll...
    unittest1.dll
    Unable to load the test container 'unittest1.dll' or one of its dependencies. If you build your test project assembly as a 64 bit assembly, it cannot be loaded. When you build your test project assembly, select "Any CPU" for the platform. To run your tests in 64 bit mode on a 64 bit processor, you must change your test settings in the Hosts tab to run your tests in a 32 bit process. Error details: Could not load file or assembly 'file:///...\TestApp\Debug\unittest1.dll' or one of its dependencies. The module was expected to contain an assembly manifest.

    Using dependency walker, it found several dependencies it couldn't resolve:

    API-MS-WIN-CORE-KERNEL32-PRIVATE-L1-1-1.DLL
    API-MS-WIN-CORE-PRIVATEPROFILE-L1-1-1.DLL
    API-MS-WIN-CORE-SHUTDOWN-L1-1-1.DLL
    API-MS-WIN-SERVICE-PRIVATE-L1-1-1.DLL
    EXT-MS-WIN-NTUSER-UICONTEXT-EXT-L1-1-0.DLL
    IESHIMS.DLL

    I found most of them scattered across my system:

    C:\Windows\System32\downlevel\API-MS-WIN-CORE-KERNEL32-PRIVATE-L1-1-1.DLL
    C:\Windows\System32\downlevel\API-MS-WIN-CORE-PRIVATEPROFILE-L1-1-1.DLL
    C:\Program Files (x86)\Microsoft Web Tools\DNX\dnx-coreclr-win-x64.1.0.0-beta5\bin\API-MS-WIN-CORE-SHUTDOWN-L1-1-1.DLL
    C:\Program Files (x86)\Microsoft Web Tools\DNX\dnx-coreclr-win-x64.1.0.0-beta5\bin\API-MS-WIN-SERVICE-PRIVATE-L1-1-1.DLL
    C:\Program Files\Internet Explorer\IESHIMS.DLL

    However, I couldn't find this one:

    EXT-MS-WIN-NTUSER-UICONTEXT-EXT-L1-1-0.DLL

    I followed the directions as specified by the following MS websites:

    Run automated tests from the command line using MSTest and Command-Line test results.

    and is how I got to this point. What seems to be the problem and how do I fix it?


    Adrian

    Thursday, September 17, 2015 7:26 PM

Answers

All replies

  • Hi Adrian,

    If you compile your test project using "Any CPU/x86", and then run it again using the command line or VS IDE, how about the result?

    >>Unable to load the test container 'unittest1.dll' or one of its dependencies. If you build your test project assembly as a 64 bit assembly, it cannot be loaded. When you build your test project assembly, select "Any CPU" for the platform. To run your tests in 64 bit mode on a 64 bit processor, you must change your test settings in the Hosts tab to run your tests in a 32 bit process. Error details: Could not load file or assembly 'file:///...\TestApp\Debug\unittest1.dll' or one of its dependencies.

    Generally this issue is related to that limitation "The MStest is 32 bit process"

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/76165bf8-3431-4591-9709-b2f965ebcf0c/mstest-running-unit-tests-in-64-bit-mode

    Thanks,

    Jack


    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.


    Friday, September 18, 2015 8:50 AM
  • If you compile your test project using "Any CPU/x86", and then run it again using the command line or VS IDE, how about the result?

    I'm running VS2013 and my project is a native application.  There is no "Any CPU/x86", only Win32 which should be a 32 bit application.  I also, as I have already said, I have no problem running the test in the VS IDE.

    Generally this issue is related to that limitation "The MStest is 32 bit process"

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/76165bf8-3431-4591-9709-b2f965ebcf0c/mstest-running-unit-tests-in-64-bit-mode

    Ok, well as I just said, the application should be a 32 bit application as it is using the default Win32 setting.


    Adrian


    • Edited by A D R I A N Friday, September 18, 2015 12:28 PM
    Friday, September 18, 2015 12:28 PM
  • Hi Adrian,

    I'm running VS2013 and my project is a native application.  There is no "Any CPU/x86", only Win32 which should be a 32 bit application.

    If so, how about add a new target for X64 for your project:

    https://msdn.microsoft.com/en-us/library/9yb4317s.aspx

    And then run it using the MSTest:

    http://blogs.msdn.com/b/danielvl/archive/2009/03/28/run-mstest-exe-as-native-64-bit-process.aspx?Redirected=true

    As you said that you project is the win32 bit project, but please make sure that whether your projects refer to certain 64 bit dll files or others.

    >>EXT-MS-WIN-NTUSER-UICONTEXT-EXT-L1-1-0.DLL.

    In addition, please also check that whether you forget to install certain library package in your side if there are no the dll files in your side. Does it work well in other machine? Maybe it is related to the windows 32bit/64 bit.

    Best Regards,

    Jack 


    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.

    Monday, September 21, 2015 8:40 AM
  • Ok, I built a x64 build.  Test in VS Test Explorer works but again, the test on the command line failed with:

    c:\...\UnitTest1\x64\Debug>mstest /testcontainer:unittest1.dll
    Microsoft (R) Test Execution Command Line Tool Version 12.0.21005.1
    Copyright (c) Microsoft Corporation. All rights reserved.

    Loading unittest1.dll...
    unittest1.dll
    Unable to load the test container 'unittest1.dll' or one of its dependencies. If you build your test project assembly as a 64 bit assembly, it cannot be loaded. When you build your test project assembly, select "Any CPU" for the platform. To run your
     tests in 64 bit mode on a 64 bit processor, you must change your test settings in the Hosts tab to run your tests in a 32 bit process. Error details: Could not load file or assembly 'file:///c:\...\UnitTest1\x64\Debug\unittest1.dll' or one of its dependencies. The module was expected to contain an assembly manifest.


    Adrian

    Monday, September 21, 2015 2:09 PM
  • Oh, forgot to use CorFlags. Using that, it stopped giving me that message and now gives me:

    c:\...\UnitTest1\x64\Debug>mstest /testcontainer:unittest1.dll /noisolation
    Microsoft (R) Test Execution Command Line Tool Version 12.0.21005.1
    Copyright (c) Microsoft Corporation. All rights reserved.

    Loading unittest1.dll...
    unittest1.dll
    File extension specified '.dll' is not a valid test extension.

    Which I don't understand.  I thought that the tests were supposed to be .dll files.

    A



    Adrian

    Monday, September 21, 2015 2:29 PM
  • Hi Adrian,

    How about running it using vstest.console.exe?

    Reference:

    http://stackoverflow.com/questions/13604691/running-native-vs2012-c-64-bit-unit-tests-from-command-line

    http://blogs.msdn.com/b/bhuvaneshwari/archive/2012/06/16/vstest-console-exe-commandline-test-runner.aspx

    Best Regards,

    Jack


    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 A D R I A N Tuesday, September 22, 2015 7:08 PM
    Tuesday, September 22, 2015 9:02 AM
  • How about running it using vstest.console.exe?

    That was the answer.  Thanks,

    A


    Adrian

    Tuesday, September 22, 2015 7:09 PM