Skip to content

[🚀 Feature]: [dotnet] Revisit unit tests infrastructure #15536

Closed

Description

@nvborisenko

Feature and motivation

Current situation is:

Image

Usage example

Concerns:

  • It could be one test project because Chrome/Edge/Firefox drivers live in one project supported by Selenium (like built-in classes).
  • Default namespace in test project is OpenQA.Selenium when usually it should be OpenQA.Selenium.Tests. I don't understand why it is unusual.
  • Avoid any static context (EnvironmentManager class) - it will allow to look at parallelization. My computer has 6/12 cores, I want to utilize all of them when running Selenium unit tests.
  • Provide a possibility to override driver options, like required in [dotnet] [bidi] Support WebExtension module #15850

Activity

  1. RenderMichael commented on Apr 2, 2025

    @RenderMichael
    Contributor

    I don't have much of the historical context surrounding the design decisions of the test projects. There are some clear reasons I see for a heavily configuration-based EnvironmentManager. For example, the EnvironmentManager.Instance property is accessible in the AssemblyFixture types.

    At the same time, I see some room for optimization.

    Notably, the above AssemblyFixture's one-time setup starts the web server and the remote server, but not the driver. The one-time teardown closes whatever driver may be opened, likely as a precaution. I fully believe we can move the "current driver" management to the test-side.

    Rather than using appconfig.json (and all the Runfiles.Create() and runfiles.Rlocation ceremony surrounding that), we can give DriverTestFixture a method like so:

    public abstract class DriverTestFixture
    {
        public abstract IWebDriver CreateDriver();
    }

    I can experiment with some potential solutions.

  2. nvborisenko commented on Apr 14, 2025

    @nvborisenko
    MemberAuthor

    Historical decision is very clear: reusing browser across 100 tests is faster than initiating new clean browser per test. I would agree at that long time ago, as a quick approach to run tests. But now I strongly disagree. Reusing shared context breaks main principle of testing: isolation. Tests should not be dependent on context, on browser state in our case. (here I could put a link to ignored test which should not be ignored). This is why we currently have NeedsFreshDriverAttribute, meaning we have to keep in mind the state of browser, shared between tests. And it is bad in my opinion.

    Tests isolation has more priority than tests execution duration. Let's say that current total duration is 20mins, introducing tests isolation will increase total duration to 40 mins. Not a problem at all, I don't see big diff between 40 mins and 20 mins. Insight: BiDi tests are executed in parallel fully isolated: 100 tests in 1.5 minutes on my machine.

    So my recommendation is also very clear: be isolated and parallelizable. Good news it is achievable.

  3. github-actions commented on Feb 7, 2026

    @github-actions
    Contributor

    This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 14 days.

  4. added
    J-staleApplied to issues that become stale, and eventually closed.
    on Feb 7, 2026
  5. removed
    J-staleApplied to issues that become stale, and eventually closed.
    on Feb 7, 2026
  6. nvborisenko commented on Jun 28, 2026

    @nvborisenko
    MemberAuthor

    Next big step is to move NUnit infrastructure into dedicated reusable project.

  7. nvborisenko commented on Oct 1, 2026

    @nvborisenko
    MemberAuthor

    NUnit infra is in dedicated project (reusable), test fixtures are parallelizable. I am confident now how it works - in IDE just run test - it runs fast.

    @YevgeniyShunevych @RenderMichael any leftovers you wanted to bring before closing this chapter (issue)?

  8. YevgeniyShunevych commented on Oct 1, 2026

    @YevgeniyShunevych
    Contributor

    I have nothing to mention.

  9. nvborisenko commented on Oct 1, 2026

    @nvborisenko
    MemberAuthor

    Sold. Thank you all for good collaboration. Next improvements will be tweak-tuning. Closing this chapter as completed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions