devops VSTest#2: ##[error]Could not find testhost - azure-devops

We are using devops to build our .net 4.7.2 application. As part of that, we are running the unit tests which are using the nunit framework and test runner.
It has been running fine for about 18 months, but has just stopped working in the last day :(
It's using the standard template for running the tests and looks like:
- task: VSTest#2
displayName: "Running tests"
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\*test*.dll
!**\*TestAdapter.dll
!**\obj\**
searchFolder: '$(System.DefaultWorkingDirectory)'
However, now it is failing the step with the following logs:
NUnit Adapter 4.2.0.0: Test execution started
Running all tests in D:\a\1\s\Configuration.Tests\bin\Release\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
NUnit3TestExecutor discovered 0 of 0 NUnit test cases using Current Discovery mode, Explicit run
Running all tests in D:\a\1\s\Configuration.Tests\bin\Release\testcentric.engine.metadata.dll
NUnit3TestExecutor discovered 0 of 0 NUnit test cases using Current Discovery mode, Explicit run
Running all tests in D:\a\1\s\Api.Tests\bin\Release\testcentric.engine.metadata.dll
NUnit3TestExecutor discovered 0 of 0 NUnit test cases using Current Discovery mode, Explicit run
Running all tests in D:\a\1\s\CommunicationTests\bin\Release\testcentric.engine.metadata.dll
NUnit3TestExecutor discovered 0 of 0 NUnit test cases using Current Discovery mode, Explicit run
Running all tests in D:\a\1\s\Domain.Tests\bin\Release\testcentric.engine.metadata.dll
NUnit3TestExecutor discovered 0 of 0 NUnit test cases using Current Discovery mode, Explicit run
Running all tests in D:\a\1\s\packages\NUnit3TestAdapter.4.2.1\build\net35\testcentric.engine.metadata.dll
NUnit3TestExecutor discovered 0 of 0 NUnit test cases using Current Discovery mode, Explicit run
NUnit Adapter 4.2.0.0: Test execution complete
No test is available in D:\a\1\s\Configuration.Tests\bin\Release\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll D:\a\1\s\Configuration.Tests\bin\Release\testcentric.engine.metadata.dll D:\a\1\s\Api.Tests\bin\Release\testcentric.engine.metadata.dll D:\a\1\s\CommunicationTests\bin\Release\testcentric.engine.metadata.dll D:\a\1\s\Domain.Tests\bin\Release\testcentric.engine.metadata.dll D:\a\1\s\packages\NUnit3TestAdapter.4.2.1\build\net35\testcentric.engine.metadata.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
##[error]Could not find testhost
Results File: D:\a_temp\TestResults\VssAdministrator_WIN-FVJ4KUK6IFI_2022-08-18_12_38_44.trx
##[error]Test Run Aborted.
Total tests: Unknown
Passed: 110
Total time: 16.7203 Seconds
Vstest.console.exe exited with code 1.
**************** Completed test execution *********************
Test results files: D:\a_temp\TestResults\VssAdministrator_WIN-FVJ4KUK6IFI_2022-08-18_12_38_44.trx
Created test run: 1080
Publishing test results: 112
Publishing test results to test run '1080'.
TestResults To Publish 112, Test run id:1080
Test results publishing 112, remaining: 0. Test run id: 1080
Published test results: 112
Publishing Attachments: 1
Execution Result Code 1 is non zero, checking for failed results
Completed TestExecution Model...
##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
##[error]Error: The process 'D:\a_tasks\VSTest_ef087383-ee5e-42c7-9a53-
ab56c98420f9\2.205.0\Modules\DTAExecutionHost.exe' failed with exit code 1
##[error]Vstest failed with error. Check logs for failures. There might be failed tests.
Finishing: Running tests
Looking through this log, it seems that the nunit tests have run successfully, but it might be trying to run mstests? It is frustrating when devops gets an update and it breaks working pipelines.

We have the similar situation.
The unit tests are run with xUnit.
/TestAdapterPath:"D:\a\1\s" Starting test execution, please wait... A
total of 36 test files matched the specified pattern.
2.4828
##[error]Could not find testhost
Data collector 'Code Coverage' message: No code coverage data
available. Profiler was not initialized..
2.0273
##[error]Could not find testhost
Data collector 'Code Coverage' message: No code coverage data
available. Profiler was not initialized..
2.3746
##[error]Could not find testhost
Data collector 'Code Coverage' message: No code coverage data
available. Profiler was not initialized..
1.992
##[error]Could not find testhost
Data collector 'Code Coverage' message: No code coverage data
available. Profiler was not initialized..
4.8409
##[error]Could not find testhost
Data collector 'Code Coverage' message: No code coverage data
available. Profiler was not initialized..
2.1874
##[error]Could not find testhost
I compared the output of the successful run and the failed run and found the different version of the test platform. If you don't specify a version, the default version will be the latest and probably a preview one. So I add something in YAML to specify a workable version.
- task: VisualStudioTestPlatformInstaller#1
inputs:
versionSelector: 'SpecificVersion'
testPlatformVersion: '17.2.0'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
codeCoverageEnabled: True
vsTestVersion: 'toolsInstaller'
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/test/vstest?view=azure-devops
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/vstest-platform-tool-installer?view=azure-devops

Related

Azure Devops - Release Pipeline when re-running failed tests azure devops shows failure status even if re-run succeeded

I use Specflow with SpecRunner+ I am using the Deafult.srprofile to to re-run failed tests 3 times in visual studio it shows 2passed 1 failed but the status of the test is a failure, the same goes for azure devops if a re-ran test passes the outcome of the run is a failure. The Failures are sometimes caused by locator timeouts or server timeouts not often but saw it happen few time thats why we decided to implement a re-run.
Could anyone help on this?
022-02-09T12:40:13.8607507Z Test Run Failed.
2022-02-09T12:40:13.8608607Z Total tests: 37
2022-02-09T12:40:13.8609271Z Passed: 36
2022-02-09T12:40:13.8609858Z Failed: 1
2022-02-09T12:40:13.8617476Z Total time: 7.4559 Minutes
2022-02-09T12:40:13.9226929Z ##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
2022-02-09T12:40:14.0075402Z ##[error]Error: The process 'D:\Microsoft_Visual_Studio\2019\Common7\IDE\Extensions\TestPlatform\vstest.console.exe' failed with exit code 1
2022-02-09T12:40:14.8164576Z ##[error]VsTest task failed.
But then the report states that it was retried 3 times which 2 of the retries were seccusefull but still a failure status on the azure devops run.
The behavior of the report is the correct one and sadly this can't be configured to be changed.
What you can do is to adjust how the results are reported back to Azure DevOps.
You can configure it via the VSTest element in the srProfile- File.
This example means, that at least one retry has to be passing:
<VSTest testRetryResults="Unified" passRateAbsolute="1"/>
Docs: https://docs.specflow.org/projects/specflow-runner/en/latest/Profile/VSTest.html
Be aware that we have stopped the development of the SpecFlow+ Runner. More details here: https://specflow.org/using-specflow/the-retirement-of-specflow-runner/

RPC Error when running more than 21 tests via VSTest adapter in Azure Devops pipeline

Our Azure DevOps pipeline seems to fails after executing exactly 21 tests. It seems like there is some invisible hard limit that's stopping execution after 21 tests. It was working last week with no changes made between then and now. I can't seem to figure out the issue so I thought I would try my luck here.
Here's the output of the failure: (Can't seem to post the full output so here's the relevant portion)
Starting the ALIFEMGSelectionTest_17 test...
Passed ALIFEMGSelectionTest_16 [48 s]
Starting the ALIFEMGSelectionTest_18 test...
Passed ALIFEMGSelectionTest_17 [49 s]
Starting the ALIFEMGSelectionTest_19 test...
Passed ALIFEMGSelectionTest_18 [54 s]
Starting the ALIFEMGSelectionTest_20 test...
Passed ALIFEMGSelectionTest_19 [1 m]
Starting the ALIFEMGSelectionTest_21 test...
Passed ALIFEMGSelectionTest_20 [59 s]
Starting the ALIFEMGSelectionTest_22 test...
Passed ALIFEMGSelectionTest_21 [59 s]
##[error]ALIFEMGSelectionTest_22 test: The remote procedure call failed. (Exception from HRESULT: 0x800706BE)
##[error]ALIFEMGSelectionTest_23 test: Unable to activate the "ALIFEMGSelectionTest_23" test due to the following error: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
Skipped ALIFEMGSelectionTest_22 [46 s]
The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
Skipped ALIFEMGSelectionTest_23
Results File: C:\_work\_temp\TestResults\admin_Desktop-09-30_15_13_56.trx
##[error]Test Run Failed.
Total tests: 21
Passed: 21
Total time: 18.7192 Minutes
Vstest.console.exe exited with code 1.
**************** Completed test execution *********************
Test results files: C:\_work\_temp\TestResults\DESKTOP.trx
Created test run: 3872
Publishing test results: 23
Publishing test results to test run '3872'.
TestResults To Publish 23, Test run id:3872
Test results publishing 23, remaining: 0. Test run id: 3872
Published test results: 23
Publishing Attachments: 1
Execution Result Code 1 is non zero, checking for failed results
Completed TestExecution Model...
##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
##[error]Error: The process 'C:\_work\_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c9\2.170.1\Modules\DTAExecutionHost.exe' failed with exit code 1
##[error]Vstest failed with error. Check logs for failures. There might be failed tests.
Finishing: VSTest

The slice of type 'Discovery' is 'Aborted' because of the error : System.Exception: NUnit Adapter 4.0.0.0: Test discovery complete

I tried to run Azure DevOps tests in a build pipeline.
Tests are executed on a new agent, i got the following error.
Setup Azure DevOps
##[error]The slice of type 'Discovery' is 'Aborted' because of the error : System.Exception: NUnit Adapter 4.0.0.0: Test discovery complete
Received the command : Stop
TestExecutionHost.ProcessCommand. Stop Command handled
SliceFetch Aborted. Moving to the TestHostEnd phase
Test run '1007278' is in 'Aborted' state.
##[error]Test run is aborted. Logging details of the run logs.
##[error]System.Exception: The test run was aborted, failing the task.
The Problem is that after slice process the test case filter isn't working, solution was the rename to “TestCategory”, before it was “Category“ for TestCaseFilter

Any idea why flaky plugin is not triggered on failed tests decorated with #pytest.mark.flaky(max_runs=...)

I have a pytest suite running in this env:
Test session starts (platform: linux, Python 3.6.1, pytest 3.3.1, pytest-sugar 0.9.1)
plugins: flaky-3.5.3, dependency-0.3.2, forked-0.2, logger-0.4.0, sugar-0.9.1, xdist-1.24.1
I have a parametrized test, decorated with flaky, and it is supposed to be re-run max three times if it fails.
#pytest.mark.flaky(max_runs=3) # re-run this test in case it fails
def test_cucubau(getBauBau_fixture):
assert cucubau(getBauBau_fixture) == True
However, it fails only once, it is not re-run, and my flaky test report is empty.
===Flaky Test Report===
===End Flaky Test Report===
Based on what I read about flaky plugin, the usage should be trivial.. but I'm not able to see what is wrong with my code.
any idea?
I believe you need the pytest-rerunfailures plugin for that to work. Then you should be able to annotate your test with #pytest.mark.flaky(reruns=3).

Azure Dev Build Release Test Execution getting aborted

Whenever I try to run the coded UI test in On-premise agent machine with Azure build-release pipeline my tests are getting aborted since yesterday. I have changed nothing on the release pipeline and build definition.
Below is the error message I am getting in the release pipeline test run console :-
2019-04-24T06:48:27.4475294Z test settings id : 1026822
2019-04-24T06:48:27.4475397Z Build location: C:\agent\_work\r1\a
2019-04-24T06:48:27.4475515Z Build Id: 5133
2019-04-24T06:48:28.0903047Z Test run with Id 1038940 associated
2019-04-24T06:48:37.6929302Z Received the command : Start
2019-04-24T06:48:37.6944608Z TestExecutionHost.ProcessCommand. Start Command handled
2019-04-24T06:48:58.8010958Z Received the command : Stop
2019-04-24T06:48:58.8011508Z TestExecutionHost.ProcessCommand. Stop Command handled
2019-04-24T06:48:58.8011845Z SliceFetch Aborted. Moving to the TestHostEnd phase
2019-04-24T06:48:58.9585180Z Please use this link to analyze the test run : 'test run URL'
2019-04-24T06:48:58.9585816Z Test run '1038940' is in 'Aborted' state with 'Total Tests' : 3 and 'Passed Tests' : 0.
2019-04-24T06:48:58.9604537Z ##[error]Test run is aborted. Logging details of the run logs.
2019-04-24T06:48:58.9606187Z ##[error]System.Exception: The test run was aborted, failing the task.
2019-04-24T06:48:59.0826921Z ##########################################################################
2019-04-24T06:48:59.1608855Z ##[section]Finishing: Test run for Test plans
I am running those test from past 6 months and I have not changed anything on the build or release pipeline and suddenly I am getting the above error on azure release pipeline test run console while triggering the run.
Note: this happened since yesterday(April 24, 2019). Till Monday(April 22, 2019) everything was working fine.
I believe there might be some changes from Microsoft end but I am not sure about that.
I am running the test on Windows 10 environment.