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

XUnit2Runner doesn't respect ParallelismOption.None #2039

Closed
kcamp opened this issue Feb 14, 2018 · 2 comments
Closed

XUnit2Runner doesn't respect ParallelismOption.None #2039

kcamp opened this issue Feb 14, 2018 · 2 comments
Milestone

Comments

@kcamp
Copy link
Contributor

kcamp commented Feb 14, 2018

What You Are Seeing?

XUnit2 is not respecting ParallelismOption.None

What is Expected?

The XUnit tool command should include the -parallel none when it's specified.

What version of Cake are you using?

0.25

Are you running on a 32 or 64 bit system?

64

What environment are you running on? Windows? Linux? Mac?

Windows

Are you running on a CI Server? If so, which one?

N/A

How Did You Get This To Happen? (Steps to Reproduce)

In consideration of this sample set of tests..

public sealed class SomeClass
{
    [Fact]
    public void OneShouldBeOne()
    {
        Thread.Sleep(5000);
        "one".Should().Be("one");
    }

    [Fact]
    public void TwoShouldBeTwo()
    {
        Thread.Sleep(5000);
        2.Should().Be(2);
    }
}

public sealed class AnotherClass
{
    [Fact]
    public void ThreeShouldBeThree()
    {
        Thread.Sleep(5000);
        3.Should().Be(3);
    }
}

When running this assembly with the task (following) I would expect the elapsed time of the tests to be 15 seconds.

XUnit2(
    assm,
    new XUnit2Settings
    {
        NoAppDomain = false,
        ShadowCopy = false,
        Parallelism = ParallelismOption.None
    });

Instead, it executes in ~10 seconds, indicating some degree of parallelism is at play.

Reading the docs at https://xunit.github.io/docs/running-tests-in-parallel.html

-parallel option 
Allows the user to specify which kinds of parallelization should be allowed for the test run. The valid option values are:
**none** Turns off all parallelization
**collections** Parallelizes collections, not assemblies
**assemblies** Parallelizes assemblies, not collections
**all** Parallelizes both collections and assemblies

The default value is collections. 

I think this last bit (defaulting to collections)is where our bug is coming into play; by suppressing the -parallel none, we're accepting the runner default.

Running that same set of tests again, manually from the CLI (below) to explicitly add the none flag gives execution time of ~15 seconds, as expected.

C:\git\sample-test-artifact> & "C:/git/sample-test-artifact/tools/xunit.runner.console.2.3.1/tools/net452/xunit.console.exe" "C:/git/sample-test-artifact/ArtifactTest/TestDiscovery.Fakes/bin/Debug/TestDiscovery.Fakes.dll" -noshadow -nunit "C:/git/sample-test-artifact/nunitTestResults/XUnitResults.xml" -parallel none

Output Log

C:\git\sample-test-artifact> .\build.ps1 -verbosity diagnostic                                                                                                                         
Preparing to run build script...                                                                                                                                                       
Running build script...                                                                                                                                                                
<snip>                                                                                                                                                                                                    
Found package 'xunit.runner.console 2.3.1' in 'C:/git/sample-test-artifact/tools'.                                                                                                     
Package xunit.runner.console.2.3.1 has already been installed.                                                                                                                         
Successfully installed 'xunit.runner.console 2.3.1' to C:/git/sample-test-artifact/tools                                                                                               
Executing nuget actions took 34.68 ms                                                                                                                                                  
<snip>                                                                                                                                   
Compiling build script...                                                                                                                                                              
                                                                                                                                                                                       
========================================                                                                                                                                               
Run-Tests                                                                                                                                                                              
========================================                                                                                                                                               
Executing task: Run-Tests                                                                                                                                                              
Executing: "C:/git/sample-test-artifact/tools/xunit.runner.console.2.3.1/tools/net452/xunit.console.exe" "C:/git/sample-test-artifact/ArtifactTest/TestDiscovery.Fakes/bin/Debug/TestDi
ery.Fakes.dll" -noshadow -nunit "C:/git/sample-test-artifact/nunitTestResults/XUnitResults.xml"                                                                                        
xUnit.net Console Runner (64-bit Desktop .NET 4.0.30319.42000)                                                                                                                         
  Discovering: TestDiscovery.Fakes                                                                                                                                                     
  Discovered:  TestDiscovery.Fakes                                                                                                                                                     
  Starting:    TestDiscovery.Fakes                                                                                                                                                     
  Finished:    TestDiscovery.Fakes                                                                                                                                                     
=== TEST EXECUTION SUMMARY ===                                                                                                                                                         
   TestDiscovery.Fakes  Total: 3, Errors: 0, Failed: 0, Skipped: 0, Time: 10.576s                                                                                                      
Finished executing task: Run-Tests                                                                                                                                                     
                                                                                                                                                                                       
========================================                                                                                                                                               
Default                                                                                                                                                                                
========================================                                                                                                                                               
Executing task: Default                                                                                                                                                                
Finished executing task: Default                                                                                                                                                       
                                                                                                                                                                                       
Task                          Duration                                                                                                                                                 
--------------------------------------------------                                                                                                                                     
Run-Tests                     00:00:11.3077021                                                                                                                                         
Default                       00:00:00.0019559                                                                                                                                         
--------------------------------------------------                                                                                                                                     
Total:                        00:00:11.3096580                                                                                                                                         
@kcamp
Copy link
Contributor Author

kcamp commented Feb 14, 2018

I will have a PR for this shortly

kcamp added a commit to kcamp/cake that referenced this issue Feb 14, 2018
@gep13 gep13 added this to the v0.27.0 milestone Feb 22, 2018
kcamp added a commit to kcamp/cake that referenced this issue Feb 27, 2018
kcamp added a commit to kcamp/cake that referenced this issue Mar 8, 2018
devlead pushed a commit to kcamp/cake that referenced this issue Mar 13, 2018
devlead added a commit that referenced this issue Mar 13, 2018
* kcamp-GH-2039:
  GH-2039: Fix XUnit2Settings + XUnit2Runner to honor explicit specifications of ParallelismOption.None
@devlead
Copy link
Member

devlead commented Mar 13, 2018

Fixed by #2040

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

No branches or pull requests

3 participants