Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaxParallelThreads does not work with Conservative parallelAlgorithm #141

Open
StanislavKlo opened this issue Jan 30, 2025 · 1 comment
Open

Comments

@StanislavKlo
Copy link

StanislavKlo commented Jan 30, 2025

Describe the bug
I've created small project with Xunit.DependencyInjection v9.8.0 with 2 simple test classes (just copy paste to reproduce the issue) :

using Xunit;

[assembly: CollectionBehavior(DisableTestParallelization = false, MaxParallelThreads = 1)] 
namespace Test.Xunit.Project;

public class Class1
{
    [Fact]
    public async Task TestOne()
    {
        await Task.Delay(10000);
        Assert.True(true);
    }
} 
<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net8.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
    </PropertyGroup>

    <ItemGroup>
      <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
      <PackageReference Include="xunit.assert" Version="2.9.3" />
      <PackageReference Include="Xunit.DependencyInjection" Version="9.8.0" />
     <PackageReference Include="xunit" Version="2.9.3" />
    </ItemGroup>
    
     <PropertyGroup>
    <ParallelizationMode>Enhance</ParallelizationMode>
  </PropertyGroup>

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

</Project>

When I run both classes, I expect that they are run sequentially (because MaxParallelThreads = 1), but they run in parallel. Meanwhile, when I use the xunit package without your library, it works perfectly, running as many tests as I specify in MaxParallelThreads.

I saw a similar issue which was closed: #111 (comment), but this does not work for me.

Could you please elaborate and suggest a fix?

@StanislavKlo
Copy link
Author

Hi @pengweiqhca, any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant