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?