locked
referencing MSTest.TestAdapter in dot executable (discovering MSTest tests in exe) RRS feed

  • Question

  • I am trying to run an all included exe (created using Costura ) on a windows VM. As per an answer in this (2nd highest voted)

    https://stackoverflow.com/questions/3402899/can-i-use-mstest-exe-without-installing-visual-studio

    I have installed test agent and build tools and trying to run exe through this command

    C:\Users\..\Desktop>"C:\Program Files (x86)\Microsoft Visual Studio\2017\TestAgent\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" MyExeName.exe /Tests: MyTestName

    on VM , I start the agent and give above command but I am receiving error

    `No test is available in C:\Users\..\Desktop\MyExeName.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.`
    I noticed (through ILSpy) that in dot exe under references, there is no reference to this
    Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll

    , however the dll is present under resources in dot exe.

    How can I maintain reference to `MSTest.TestAdapter` in dot exe and make sure MSTest tests are discoverable through exe ?




    • Edited by h0704 Tuesday, February 4, 2020 7:50 PM
    Tuesday, February 4, 2020 7:46 PM

All replies

  • Hi h0704,

    Welcome to MSDN forum.

    For your requirement, you could have a try to specify the test adapter using argument "/TestAdapterPath:", please refer this command:

    D:\>vstest.console.exe [Name].exe /TestAdapterPath:[path]

    And please confirm if these files are under your source path:

    Any feedback will be epxected.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, February 5, 2020 9:19 AM
  • Hello

         Thank you for response

          Do you mean that this package "MSTest.TestAdapter.2.1.0" should be physically present on VM and then I should try to give command as 

    D:\>vstest.console.exe [Name].exe /TestAdapterPath:[C:\SomeFolder\MSTest.TestAdapter.2.1.0\build\_common\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll]

    The files you mention are there in exe except the two xml files.  They are there under resources . I peeked into exe through ILSpy . I am not sure what you mean by "source path"

    My requirement is to run this exe through "vstest.console"  with as less code as possible on the VM . Thats why I packaged everything in executable using costura. How can I achieve that ?

    Thank You


    Wednesday, February 5, 2020 6:21 PM
  • Hi h0704,

    Thank you for feedback.

    For your requirement, I try to delete "....TestFramework.extension.dll" and "....TestFramework.dll" which has been referenced into exe in the output path, then I run exe file using vstest.console.exe, it also throws "No test is available ...".

    According to it, the vstest.console.exe seems to need to load TestAdapter components individually and the loading path is default same as exe file. So, you need to copy these dlls to the folder where the exe locates in VM.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Thursday, February 6, 2020 10:58 AM
  • Hello

      Those files are already present in the executable under \bin\debug folder . How do I reference that in the vstest.console.exe command.

    Alternatively , do you know any other way to load TestAdapter components from executable?

    Thank You

    Thursday, February 6, 2020 11:10 PM
  • Hello 

       Can anyone please comment on how do we get `vstest.console.exe` from command line  to resolve assemblies that are available  from Main() method of an executable.

    Thanks

    Sunday, February 9, 2020 3:18 PM
  • Hi h0704,

    Sorry for delay in reply.

    You just need to make these dlls into the same folder, then type the below command:

    D:\>vstest.console.exe [Name].exe

    You could refer this sample here:

    #1,my test.exe

    #2, run it in command prompt tool:

    Hope it could help you.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Wednesday, February 12, 2020 10:03 AM
  • Thank You for your reply.

    As I mentioned earlier , I have a requirement where I would not like to have dlls in folder physically on the drive.

    I would like to have dlls available to command line `vstest.console.exe` from my executable at runtime. I am packaging all dlls in my executable through costura.fody

    I would like to give more information to you from stackOverflow but this forum wouldn't  let me put any hyperlinks(how can I verify my account?)

    Thursday, February 13, 2020 1:10 AM
  • Hi h0704,

    Thank you for reply.

    When you package all dlls into your exe file, the references are just used by executable. But the vstest.console.exe needs to additionally load these dlls in specified pysical path. So I'm afraid we cannot implement it, sorry for this inconvenience.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, February 14, 2020 9:52 AM