问题
I am trying to run an all included exe (created using Costura ) on a windows VM. As per an answer in this SO question , 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.
The exe runs fine on local machine using same command and start tests. On local I have VS2019 and all the code. On VM , I can not have VS and code base as a requirement.
EDIT:
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 in resources.
回答1:
I could reproduce this error... I did some experiments on my csproj file and it turns out you have to add an Import tag in your console csproj file. This has nothing to do with your test agent or test class.
Check your package.config (ps. this is 2019, so check your version) MSTest.TestAdapter has to be added.
<package id="MSTest.TestAdapter" version="1.3.2" targetFramework="net48" />
Secondly, add the Import tag to your csproj file. (and again check your version)
<Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" />
When importing this project a few more items are being added to your project.
And this results into this output
See screenshots below for test case 1 (not working) and 2 (working)
Test 1:
Test 2:
I hope this is working on your end!!
Solution and project:
来源:https://stackoverflow.com/questions/60044624/no-test-available-test-through-exe-using-build-tools-and-test-agent-on-vm