microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.41k stars 3.63k forks source link

[Question] How to disable parallel execution with .Net #11501

Closed davidhprotective closed 2 years ago

davidhprotective commented 2 years ago

I am using PW with .Net and currently my tests are running in parallel. How can I disable parallel running by default?

ltsuda commented 2 years ago

Are you using NUnit ?

As state in the following link, it runs tests in parallel by default but maybe if you set NUnit.NumberOfTestWorkers to 1 worker, the tests will not run in parallel. https://playwright.dev/dotnet/docs/test-runners#running-nunit-tests-in-parallel

Also, if you are running from Visual Studio, you can set NUnit.NumberOfTestWorkers to 1 in the .runsettings configuration file. https://playwright.dev/dotnet/docs/test-runners#using-the-runsettings-file

If this doesn't work, let's wait for someone from the Playwright team or someone who uses .NET and have the knowledge to share.

davidhprotective commented 2 years ago

I am using a combination of both xUnit and Specflow BDD so there are two entry points to the test execution when I run all tests together with dotnet run. I am looking if Playwright offers a solution to manage all tests in this case to run sequentially.

mxschmitt commented 2 years ago

Playwright in .NET is just a library, you can use whatever test-runner you want with it. We recommend nunit because it shown us to have the best support for parallelism compared to other test-runners.

See here for our recommended nunit setup: https://playwright.dev/dotnet/docs/test-runners#running-nunit-tests-in-parallel

Since we neither use Specflow nor xunit in Playwright for .NET we can't act on this but these links might be helpful: