Skip to content

Commit

Permalink
docs(dotnet): TestRunParameters -> Playwright runsettings node
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Aug 12, 2022
1 parent dc07a60 commit 7a2b37c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 68 deletions.
23 changes: 6 additions & 17 deletions docs/src/running-tests-csharp.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,13 @@ You can run a single test, a set of tests or all tests. Tests can be run on diff

- Running Tests on specific browsers

```bash tab=bash-bash
BROWSER=webkit dotnet test
```

```batch tab=bash-batch
set BROWSER=webkit
dotnet test
```

```powershell tab=bash-powershell
$env:BROWSER="webkit"
dotnet test
```bash
dotnet test -- Playwright.BrowserName=webkit
```

- Running Tests on multiple browsers

To run your test on multiple browsers or configurations you need to invoke the `dotnet test` command multiple times. There you can then either specify the `BROWSER` environment variable (like the previous) or pass the `browser` via the runsettings file:
To run your test on multiple browsers or configurations you need to invoke the `dotnet test` command multiple times. There you can then either specify the `BROWSER` environment variable or set the `Playwright.Browser` via the runsettings file:

```bash
dotnet test --settings:chromium.runsettings
Expand All @@ -58,10 +48,9 @@ You can run a single test, a set of tests or all tests. Tests can be run on diff
```xml
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<TestRunParameters>
<Parameter name="browser" value="chromium" />
<Parameter name="headless" value="false" />
</TestRunParameters>
<Playwright>
<BrowserName>chromium</BrowserName>
</Playwright>
</RunSettings>
```

Expand Down
97 changes: 46 additions & 51 deletions docs/src/test-runners-csharp.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,18 @@ CLI. See the following example:
```xml
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<TestRunParameters>
<Parameter name="browser" value="chromium" />
<Parameter name="headless" value="false" />
<Parameter name="channel" value="msedge" />
</TestRunParameters>
<Playwright>
<BrowserName>chromium</BrowserName>
<LaunchOptions>
<Headless>false</Headless>
<Channel>msedge</Channel>
</LaunchOptions>
</Playwright>
</RunSettings>
```

```bash tab=bash-bash
dotnet test -- TestRunParameters.Parameter\(name=\"browser\", value=\"chromium\"\) TestRunParameters.Parameter\(name=\"headless\", value=\"false\"\) TestRunParameters.Parameter\(name=\"channel\", value=\"msedge\"\)
```

```batch tab=bash-batch
dotnet test -- TestRunParameters.Parameter(name=\"browser\", value=\"chromium\") TestRunParameters.Parameter(name=\"headless\", value=\"false\") TestRunParameters.Parameter(name=\"channel\", value=\"msedge\")
```

```powershell tab=bash-powershell
dotnet test -- TestRunParameters.Parameter(name=\"browser\", value=\"chromium\") TestRunParameters.Parameter(name=\"headless\", value=\"false\") TestRunParameters.Parameter(name=\"channel\", value=\"msedge\")
```bash
dotnet test -- Playwright.Browser=chromium Playwright.LaunchOptions.Headless=false Playwright.LaunchOptions.Channel=msedge
```

### Using Verbose API Logs
Expand All @@ -180,29 +174,33 @@ When you have enabled the [verbose API log](./debug.md#verbose-api-logs), via th

### Using the .runsettings file

When running tests from Visual Studio, you can take advantage of the `.runsettings` file.
When running tests from Visual Studio, you can take advantage of the `.runsettings` file. The following shows a reference of the supported values.

For example, to specify the amount of workers (`NUnit.NumberOfTestWorkers`), you can use the following snippet:
For example, to specify the amount of workers you can use `NUnit.NumberOfTestWorkers` or to enable `DEBUG` logs `RunConfiguration.EnvironmentVariables`.

```xml
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- NUnit adapter -->
<NUnit>
<NumberOfTestWorkers>24</NumberOfTestWorkers>
</NUnit>
</RunSettings>
```

If you want to enable debugging, you can set the `DEBUG` variable to `pw:api` as documented, by doing:

```xml
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- General run configuration -->
<RunConfiguration>
<EnvironmentVariables>
<!-- For debugging selectors, it's recommend to set the following environment variable -->
<DEBUG>pw:api</DEBUG>
</EnvironmentVariables>
</RunConfiguration>
<!-- Playwright -->
<Playwright>
<BrowserName>chromium</BrowserName>
<ExpectTimeout>5000</ExpectTimeout>
<LaunchOptions>
<Headless>true</Headless>
<Channel>msedge</Channel>
</LaunchOptions>
</Playwright>
</RunSettings>
```

Expand Down Expand Up @@ -363,24 +361,18 @@ CLI. See the following example:
```xml
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<TestRunParameters>
<Parameter name="browser" value="chromium" />
<Parameter name="headless" value="false" />
<Parameter name="channel" value="msedge" />
</TestRunParameters>
<Playwright>
<BrowserName>chromium</BrowserName>
<LaunchOptions>
<Headless>false</Headless>
<Channel>msedge</Channel>
</LaunchOptions>
</Playwright>
</RunSettings>
```

```bash tab=bash-bash
dotnet test -- TestRunParameters.Parameter\(name=\"browser\", value=\"chromium\"\) TestRunParameters.Parameter\(name=\"headless\", value=\"false\"\) TestRunParameters.Parameter\(name=\"channel\", value=\"msedge\"\)
```

```batch tab=bash-batch
dotnet test -- TestRunParameters.Parameter(name=\"browser\", value=\"chromium\") TestRunParameters.Parameter(name=\"headless\", value=\"false\") TestRunParameters.Parameter(name=\"channel\", value=\"msedge\")
```

```powershell tab=bash-powershell
dotnet test -- TestRunParameters.Parameter(name=\"browser\", value=\"chromium\") TestRunParameters.Parameter(name=\"headless\", value=\"false\") TestRunParameters.Parameter(name=\"channel\", value=\"msedge\")
```bash
dotnet test -- Playwright.Browser=chromium Playwright.LaunchOptions.Headless=false Playwright.LaunchOptions.Channel=msedge
```

### Using Verbose API Logs
Expand All @@ -389,32 +381,35 @@ When you have enabled the [verbose API log](./debug.md#verbose-api-logs), via th

### Using the .runsettings file

When running tests from Visual Studio, you can take advantage of the `.runsettings` file.
When running tests from Visual Studio, you can take advantage of the `.runsettings` file. The following shows a reference of the supported values.

For example, to specify the amount of workers (`MSTest.Parallelize.Workers`), you can use the following snippet:
For example, to specify the number of workers, you can use `MSTest.Parallelize.Workers`. You can also enable `DEBUG` logs using `RunConfiguration.EnvironmentVariables`.

```xml
<RunSettings>
<!-- MSTest adapter -->
<!-- MSTest adapter -->
<MSTest>
<Parallelize>
<Workers>4</Workers>
<Scope>ClassLevel</Scope>
</Parallelize>
</MSTest>
</RunSettings>
```

If you want to enable debugging, you can set the `DEBUG` variable to `pw:api` as documented, by doing:

```xml
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- General run configuration -->
<RunConfiguration>
<EnvironmentVariables>
<!-- For debugging selectors, it's recommend to set the following environment variable -->
<DEBUG>pw:api</DEBUG>
</EnvironmentVariables>
</RunConfiguration>
<!-- Playwright -->
<Playwright>
<BrowserName>chromium</BrowserName>
<ExpectTimeout>5000</ExpectTimeout>
<LaunchOptions>
<Headless>false</Headless>
<Channel>msedge</Channel>
</LaunchOptions>
</Playwright>
</RunSettings>
```

Expand Down

0 comments on commit 7a2b37c

Please sign in to comment.