Skip to content

Slow performance on discovery / running due to discovering TestReporters #317

Closed
@kiwidev

Description

@kiwidev

Once a test project has a number of files inside the output folder, then discovery of test reporters can add significant time onto both discovery and run phases inside Visual Studio. On a project with 100 dlls + regional versions (not a large number with modern libs), iterating through all of the dlls is adding on 1-3 seconds to each phase. This makes for a slow red-green-refactor cycle inside VS. (The current code iterates through every type inside every dll in the output folder).

I've done some local tests where I explicitly specified the list of dlls containing reporters (e.g. xunit.runner.reporters.netcoreapp10.dll) inside a runsettings file and this eliminated the overhead / reduced it to < 50ms. As an example, with a simple project this takes the "run test" process after changing a file (discovery and then run, excluding build) from 4 seconds to 1.5.

Would the team be open to some sort of explicit flag like this inside runsettings or xunit config? Or is there a better way to do it?

Example (additional logging inserted by me, warm runs with fast NVMe disk, VS2022):

========== Starting test discovery ==========
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.6-preview.3+7479759cc5 (64-bit .NET 6.0.5)
[xUnit.net 00:00:00.08] Get runner reporter
[xUnit.net 00:00:01.31] After Get runner reporter
[xUnit.net 00:00:01.36]   Discovering: Foo.RedactedTests
[xUnit.net 00:00:01.73]   Discovered:  Foo.RedactedTests
========== Test discovery finished: 400 Tests found in 2.3 sec ==========
Executing test method: Foo.RedactedTests.EmptyTest
Using automatically detected runsettings file(s). To learn more visit https://aka.ms/vs-runsettings.
========== Starting test run ==========
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.6-preview.3+7479759cc5 (64-bit .NET 6.0.5)
[xUnit.net 00:00:00.02] Get runner reporter
[xUnit.net 00:00:01.24] After get runner reporter
[xUnit.net 00:00:01.32]   Starting:    Foo.RedactedTests
[xUnit.net 00:00:01.47]   Finished:    Foo.RedactedTests
========== Test run finished: 1 Tests (1 Passed, 0 Failed, 0 Skipped) run in 1.5 sec ==========

With config on:

========== Starting test discovery ==========
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.6-preview.3+7479759cc5 (64-bit .NET 6.0.5)
[xUnit.net 00:00:00.09] Get runner reporter
[xUnit.net 00:00:00.11] After Get runner reporter
[xUnit.net 00:00:00.21]   Discovering: Foo.RedactedTests
[xUnit.net 00:00:00.54]   Discovered:  Foo.RedactedTests
========== Test discovery finished: 400 Tests found in 1.2 sec ==========
Executing test method: Foo.RedactedTests.EmptyTest
Using automatically detected runsettings file(s). To learn more visit https://aka.ms/vs-runsettings.
========== Starting test run ==========
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.6-preview.3+7479759cc5 (64-bit .NET 6.0.5)
[xUnit.net 00:00:00.02] Get runner reporter
[xUnit.net 00:00:00.04] After get runner reporter
[xUnit.net 00:00:00.16]   Starting:    Foo.RedactedTests
[xUnit.net 00:00:00.29]   Finished:    Foo.RedactedTests
========== Test run finished: 1 Tests (1 Passed, 0 Failed, 0 Skipped) run in 310 ms ==========

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions