Tom
Tom

Reputation: 665

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

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.

Upvotes: 3

Views: 3010

Answers (1)

tomato
tomato

Reputation: 86

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

Upvotes: 7

Related Questions