Can't run vstest

Bernhard Sumser 111 Reputation points
2022-11-30T10:32:36.047+00:00

Hello all,
I try to automate the UnitTests for our Azure Build Pipeline, but getting this error:

Starting: Test run for Test plans  
==============================================================================  
Task         : Visual Studio Test  
Description  : Run unit and functional tests (Selenium, Appium, Coded UI test, etc.) using the Visual Studio Test (VsTest) runner. Test frameworks that have a Visual Studio test adapter such as MsTest, xUnit, NUnit, Chutzpah (for JavaScript tests using QUnit, Mocha and Jasmine), etc. can be run. Tests can be distributed on multiple agents using this task (version 2).  
Version      : 2.210.0  
Author       : Microsoft Corporation  
Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/test/vstest  
==============================================================================  
SystemVssConnection exists true  
SystemVssConnection exists true  
In distributed testing flow  
======================================================  
Test selector : Test run  
Test run Id : 'NaN'  
Search folder : D:\a\1\s  
Action when minimum tests threshold not met : donothing  
Minimum tests expected to be run: 0  
VisualStudio version selected for test execution : latest  
Attempting to find vstest.console from a visual studio installation with version [17.0,18.0).  
Distributed test execution, number of agents in job : 1  
Run in parallel : false  
Run in isolation : false  
Path to custom adapters : null  
Other console options : null  
Code coverage enabled : false  
Diagnostics enabled : false  
======================================================  
Source filter: **\*test*.dll,!**\*TestAdapter.dll,!**\obj\**  
SystemVssConnection exists true  
D:\a\_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.210.0\Modules\DTAExecutionHost.exe --inputFile D:\a\_temp\input_acf2b0d1-7089-11ed-aac5-1b585eed5c43.json  
##########################################################################  
DtaExecutionHost version 19.210.32906.4.  
##[error]Input validation failed with exception: Invalid on demand test run id 0. Has to be greater than 0.  
##[error]Error: The process 'D:\a\_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.210.0\Modules\DTAExecutionHost.exe' failed with exit code 1  
Finishing: Test run for Test plans  

This is the yml code I use in the Azure Pipeline so far

- task: VisualStudioTestPlatformInstaller@1  
  inputs:  
    packageFeedSelector: 'nugetOrg'  
    versionSelector: 'latestStable'  

When I run dotnet vstest .\path\to\unittests.dll on my machine I get this error

Microsoft (R) Test Execution Command Line Tool Version 17.4.0 (x64)  
Copyright (c) Microsoft Corporation.  All rights reserved.  
  
Starting test execution, please wait...  
A total of 1 test files matched the specified pattern.  
No test is available in C:\Data\dev\sales\.\UnitTests\UnitTests.Account\bin\Debug\Plugins.Account.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.  
  
Additionally, path to test adapters can be specified using /TestAdapterPath command. Example  /TestAdapterPath:<pathToCustomAdapters>.  

The package.config does look like that.

<?xml version="1.0" encoding="utf-8"?>  
<packages>  
  <package id="MSTest.TestAdapter" version="2.2.10" targetFramework="net471" />  
  <package id="MSTest.TestFramework" version="2.2.10" targetFramework="net471" />  
</packages>  

The strange thing is that I can run the tests in the VS 2022 Test Explorer.

Any ideas what I am missing?

Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
337 questions
0 comments No comments
{count} votes

Accepted answer
  1. Anna Xiu-MSFT 27,731 Reputation points Microsoft Vendor
    2022-12-01T02:56:38.787+00:00

    Hi @Bernhard Sumser ,

    Welcome to Microsoft Q&A!

    You issue is more related to Azure Pipeline, please report it in dedicated Azure Pipeline forum:
    https://developercommunity.visualstudio.com/AzureDevOps/report?entry=problem

    Thanks for your understanding!

    Sincerely,
    Anna
    *
    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Bernhard Sumser 111 Reputation points
    2022-12-01T08:28:30.317+00:00

    Thanks for the link Anna. Sorry my bad. After switching the language, I didn't looked at the site I got redirected.

    0 comments No comments