xunit / visualstudio.xunit

VSTest runner for xUnit.net (for Visual Studio Test Explorer and dotnet test)
https://xunit.net/
Other
145 stars 81 forks source link

Stuck at "Starting" in Azure Devops #344

Closed kedzior-io closed 1 year ago

kedzior-io commented 1 year ago

Here is my setup:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <IsPackable>false</IsPackable>
        <ProduceReferenceAssembly>false</ProduceReferenceAssembly>
        <LangVersion>latest</LangVersion>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
        <RunSettingsFilePath>$(MSBuildProjectDirectory)\tests.runsettings</RunSettingsFilePath>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.9" />
        <PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
        <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
        <PackageReference Include="xunit" Version="2.4.2" />
        <PackageReference Include="Xunit.DependencyInjection" Version="8.5.0" />
        <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
            <PrivateAssets>all</PrivateAssets>
        </PackageReference>
    </ItemGroup>

    <ItemGroup>
      <ProjectReference Include="..\MyProject.csproj" />
    </ItemGroup>

</Project>

Here is the task setup:

image

When running, half time it succedes, other times it gets stuck for hours.

Run Attachments will be stored in LogStore
Result Attachments will be stored in LogStore
Result Attachments will be stored in LogStore
Run Attachments will be stored in LogStore
Updated Run Settings:
<RunSettings>
  <RunConfiguration>
    <BatchSize>1000</BatchSize>
    <ResultsDirectory>D:\a\_temp\TestResults</ResultsDirectory>
  </RunConfiguration>
</RunSettings>
**************** Starting test execution *********************
[command]C:\hostedtoolcache\windows\VsTest\17.3.1\x64\tools\net451\Common7\IDE\Extensions\TestPlatform\vstest.console.exe "@D:\a\_temp\oynkfvbad3o.tmp"
Microsoft (R) Test Execution Command Line Tool Version 17.3.1 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.
vstest.console.exe "D:\a\r1\a\MyProject.IntegrationTests.dll"
/Settings:"D:\a\_temp\inioycq0efi.tmp.runsettings"
/Logger:"trx"
/TestAdapterPath:"D:\a\r1\a"
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.5+1caef2f33e (64-bit .NET 6.0.8)
[xUnit.net 00:00:01.33]   Discovering: MyProject.IntegrationTests
[xUnit.net 00:00:01.37]   Discovered:  MyProject.IntegrationTests
[xUnit.net 00:00:01.37]   Starting:    MyProject.IntegrationTests

This started happening when I switched from dotnet 5 to 6.

Tests are working fine when executed on developer machine.

kedzior-io commented 1 year ago

Ok seems like adding that solved my problem:

    <ItemGroup>
      <None Update="xunit.runner.json">
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
      </None>
    </ItemGroup>

xunit.runner.json

{
    "parallelizeTestCollections": false,
    "maxParallelThreads": -1
}