6

The build runs well but can not see the unit test result When added a build pipeline which used a classic edit or for my solution.

And the code coverage also blank. I have two projects and tests project in the solution. The unit test task returns the result as below:

    A total of 14 test files matched the specified pattern.
           No test is available in d:\a\1\s\src.net... 
Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
            Results File: d:\a\_temp\TestResults\VssAdministrator_fv-az686_2019-12-26_06_10_28.trx
            Attachments:
              d:\a\_temp\TestResults\d301a26b-d99f-4b4e-bbe8-c95e588ee1c5\VssAdministrator_fv-az686 2019-12-26 06_10_20.coverage
            Vstest.console.exe exited with code 0.
            **************** Completed test execution *********************
            Test results files: d:\a\_temp\TestResults\VssAdministrator_fv-az686_2019-12-26_06_10_28.trx
            No Result Found to Publish 'd:\a\_temp\TestResults\VssAdministrator_fv-az686_2019-12-26_06_10_28.trx'.
            Created test run: 1006840
            Publishing test results: 0
            Publishing test results to test run '1006840'.
            TestResults To Publish 0, Test run id:1006840
            Published test results: 0
            Publishing Attachments: 2
            Completed TestExecution Model...

And also I can not see anymore from the Tests windows.

The test YAML script as below:

steps:
- task: VSTest@2
  displayName: 'Test Assemblies'
  inputs:
    testAssemblyVer2: |
     **\$(BuildConfiguration)\*test*.dll
     !**\obj\**
    codeCoverageEnabled: true
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'
Kevin YANG
  • 411
  • 2
  • 8
  • 23

1 Answers1

3

There no any problem on your YAML, the same definition is all work for me.

A total of 14 test files matched the specified pattern.

No test is available in d:\a\1\s\src.net...

Based on these error message, the test files has been identified out from the folder which means the dlls has exists now. But it still say there's no test available, this is more relative with vstest.console.exe did not identify the test.

For example, if your test project type is NUnit, you could use one extension names NUnit test adapter to support this test type running in visual studio.

But, when the project is published into VSTS, this extension could not be published also, and this extension does not exists in VSTS hosted agent. Without this extension support, the vstest.console.exe could not identify the Nunit test, then it will prompt the message like No test is available in xxxxxxx. See this as refer to.

But, you can installed nuget packages to replace the role of that VS extension.

If it's type is Nunit test, you must ensure add the reference on packages NUnit and NUnit3TestAdapter in your csproj file:

<PackageReference Include="NUnit">
      <Version>3.12.0</Version>
    </PackageReference>
<PackageReference Include="NUnit3TestAdapter">
      <Version>3.15.1</Version>
    </PackageReference>

Similar method tp xUnit test.

Community
  • 1
  • 1
Mengdi Liang
  • 17,577
  • 2
  • 28
  • 35
  • The package already added in my nuget package config file,do you mean I also have to add the config in my csproj file in order to help the pipeline build identify the test project? The config as below: – Kevin YANG Dec 30 '19 at 00:50
  • Hi @Merlin Liang,after I ran the pipeline,another information will show:Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again. PS:my project is MSTest Test project – Kevin YANG Dec 30 '19 at 07:12
  • @element8763, **1.** For the latest comment, that line shows that our system did not detect out the test/framwork version and etc the script provided. So it let you please make sure they are exists. **2.** does the script you mentioned in first comment is in config? Based on my experience, this systax ` is in csproj`. If you do not mind, could you show me one sample on your project? Or just share me the file of your `csproj`? – Mengdi Liang Dec 30 '19 at 08:19
  • Regarding to 2,it is a part of csproj files.I just do a test solution,and add a pipeline on azure devops.,still the same errors.You can find the code [link](https://dev.azure.com/kevinyangfan/UnitTestSolution/_git/UnitTestSolution)@Merlin Liang - MSFT – Kevin YANG Dec 30 '19 at 08:39
  • @element8763, I saw that the mstest is using .net core. So please try with using dotnet restore/build/test to compile the project. This is my result which run based on your code: https://dev.azure.com/ForMerlin/MStest/_build/results?buildId=1462&view=ms.vss-test-web.build-test-results-tab (Just ignore the publish task, I did not specify the argument in it but its failure is not affect the test) – Mengdi Liang Dec 30 '19 at 09:35
  • @element8763, I don't know why the build is display not found if others is not member of my org. So I took a screenshot of it: https://imgur.com/a/O4gdhe6 . I put 2 screenshots in that link. One is the tab of my test summary, and another is the test log. – Mengdi Liang Dec 30 '19 at 09:44
  • Thanks,I saw the tests results. But for my pipeline,i also use .netcore and .net framework project,they are all failed.I tried to find the differences between the configurations but can not find the proper process. Can you please share me some configurations for this project pipeline on azuredevops?@Merlin Liang - MSFT – Kevin YANG Dec 30 '19 at 11:17
  • @element8763, I am reproducing the project of yours. Please see these screenshots: https://imgur.com/a/30rLy8g to get my build definition. – Mengdi Liang Dec 30 '19 at 11:23
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/205072/discussion-between-merlin-liang-msft-and-element8763). – Mengdi Liang Dec 30 '19 at 11:23