Skip to content

Commit 7ebea0a

Browse files
committed
added Nunit docs
1 parent 2fa427e commit 7ebea0a

File tree

3 files changed

+127
-54
lines changed

3 files changed

+127
-54
lines changed

articles/playwright-testing/how-to-manage-authentication.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ description: Learn how to manage authentication and authorization for Microsoft
44
ms.topic: how-to
55
ms.date: 09/07/2024
66
ms.custom: playwright-testing-preview
7+
zone_pivot_group_filename: playwright-testing/ZonePivotGroups.json
8+
zone_pivot_groups: microsoft-playwright-testing
79
---
810

911
# Manage authentication and authorization for Microsoft Playwright Testing preview
@@ -48,6 +50,7 @@ To enable authentication using access tokens:
4850
> Authentication using access tokens is less secure. [Learn how to manage access tokens](./how-to-manage-access-tokens.md)
4951
5052
## Set up authentication using access-tokens
53+
::: zone pivot="playwright-test-runner"
5154

5255
1. While running the tests, enable access token auth in the `playwright.service.config.ts` file in your setup.
5356

@@ -57,15 +60,28 @@ To enable authentication using access tokens:
5760
serviceAuthType:'ACCESS_TOKEN'
5861
}));
5962
```
63+
::: zone-end
64+
65+
::: zone pivot="nunit-test-runner"
66+
1. While running the tests, enable access token auth in the `.runsettings` file in your setup.
67+
68+
```xml
69+
<TestRunParameters>
70+
<!-- Use this option when you want to authenticate using access tokens. This mode of auth should be enabled for the workspace. -->
71+
<Parameter name="ServiceAuthType" value="EntraId" />
72+
</TestRunParameters>
73+
```
74+
::: zone-end
6075

6176
1. Create access token
6277

6378
Follow the steps to [create an access token](./how-to-manage-access-tokens.md#generate-a-workspace-access-token)
6479

80+
6581
1. Set up your environment
6682

6783
To set up your environment, you have to configure the `PLAYWRIGHT_SERVICE_ACCESS_TOKEN` environment variable with the value you obtained in the previous steps.
68-
84+
::: zone pivot="playwright-test-runner"
6985
We recommend that you use the `dotenv` module to manage your environment. With `dotenv`, you define your environment variables in the `.env` file.
7086

7187
1. Add the `dotenv` module to your project:
@@ -82,15 +98,26 @@ To enable authentication using access tokens:
8298

8399
Make sure to replace the `{MY-ACCESS-TOKEN}` text placeholder with the value you copied earlier.
84100

101+
::: zone-end
85102

103+
::: zone pivot="nunit-test-runner"
104+
Make sure this environment variable is available in your setup where you are running tests.
105+
::: zone-end
86106
## Run tests on the service and publish results
87107

88108
Run Playwright tests against cloud-hosted browsers and publish the results to the service using the configuration you created above.
89109

110+
::: zone pivot="playwright-test-runner"
90111
```typescript
91112
npx playwright test --config=playwright.service.config.ts --workers=20
92113
```
114+
::: zone-end
93115

116+
::: zone pivot="nunit-test-runner"
117+
```bash
118+
dotnet test --settings:.runsettings --logger "microsoft-playwright-testing" -- NUnit.NumberOfTestWorkers=20
119+
```
120+
::: zone-end
94121
## Related content
95122

96123
- Learn more about [managing access tokens](./how-to-manage-access-tokens.md).

articles/playwright-testing/how-to-use-service-features.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ description: Learn how to use different features offered by Microsoft Playwright
44
ms.topic: how-to
55
ms.date: 09/07/2024
66
ms.custom: playwright-testing-preview
7+
zone_pivot_group_filename: playwright-testing/ZonePivotGroups.json
8+
zone_pivot_groups: microsoft-playwright-testing
79
---
810

911
# Use features of Microsoft Playwright Testing preview
@@ -48,7 +50,7 @@ You can also choose to use either feature or both for a test run.
4850

4951
> [!IMPORTANT]
5052
> You can only use a feature in a test run if it is enabled for the workspace.
51-
53+
::: zone pivot="playwright-test-runner"
5254
1. In your Playwright setup, go to `playwright.service.config.ts` file and use these settings for feature management.
5355

5456
```typescript
@@ -87,7 +89,51 @@ export default defineConfig(
8789
["@azure/microsoft-playwright-testing/reporter"]],
8890
```
8991

92+
::: zone-end
93+
94+
::: zone pivot="nunit-test-runner"
95+
96+
1. In your Playwright setup, go to `.runsettings` file and use these settings for feature management.
97+
98+
```xml
99+
<?xml version="1.0" encoding="utf-8"?>
100+
<RunSettings>
101+
<TestRunParameters>
102+
<!--Select if you want to use cloud-hosted browsers to run your Playwright tests.-->
103+
<Parameter name="UseCloudHostedBrowsers" value="true" />
104+
</TestRunParameters>
105+
<!-- NUnit adapter -->
106+
.
107+
.
108+
.
109+
<LoggerRunSettings>
110+
<Loggers>
111+
<!--microsoft playwright testing service logger for reporting -->
112+
<Logger friendlyName="microsoft-playwright-testing" enabled="True" />
113+
<!--could enable any logger additionally -->
114+
<Logger friendlyName="trx" enabled="false" />
115+
</Loggers>
116+
</LoggerRunSettings>
117+
</RunSettings>
118+
119+
```
90120

121+
* **`useCloudHostedBrowsers`**
122+
- **Description**: This setting allows you to choose whether to use cloud-hosted browsers or the browsers on your client machine to run your Playwright tests. If you disable this option, your tests run on the browsers of your client machine instead of cloud-hosted browsers, and you don't incur any charges.
123+
- **Default Value**: true
124+
- **Example**:
125+
```xml
126+
<Parameter name="UseCloudHostedBrowsers" value="true" />
127+
```
128+
129+
* **`reporter`**
130+
- **Description**: You can publish your test results and artifacts to the service using `microsoft-playwright-testing` logger. You can disable reporting by removing this from your `.runsettings` or by setting it to false.
131+
- **Default Value**: true
132+
- **Example**:
133+
```xml
134+
<Logger friendlyName="microsoft-playwright-testing" enabled="True" />
135+
```
136+
::: zone-end
91137
## Related content
92138

93139
- Learn more about [Microsoft Playwright Testing preview pricing](https://aka.ms/mpt/pricing).

articles/playwright-testing/quickstart-automate-end-to-end-testing.md

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -240,59 +240,59 @@ Update the CI workflow definition to run your Playwright tests with the Playwrig
240240
# [GitHub Actions](#tab/github)
241241

242242
```yml
243-
on:
244-
push:
245-
branches: [ main, master ]
246-
pull_request:
247-
branches: [ main, master ]
248-
permissions: # Required when using AuthType as EntraId
249-
id-token: write
250-
contents: read
251-
jobs:
252-
test:
253-
timeout-minutes: 60
254-
runs-on: ubuntu-latest
255-
steps:
256-
- uses: actions/checkout@v4
257-
# This step is to sign-in to Azure to run tests from GitHub Action workflow.
258-
# Choose how to set up authentication to Azure from GitHub Actions. This is one example.
259-
260-
- name: Login to Azure with AzPowershell (enableAzPSSession true)
261-
uses: azure/login@v2
262-
with:
263-
client-id: ${{ secrets.AZURE_CLIENT_ID }}
264-
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
265-
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
266-
enable-AzPSSession: true
267-
268-
- name: Setup .NET
269-
uses: actions/setup-dotnet@v4
270-
with:
271-
dotnet-version: 8.0.x
272-
273-
- name: Restore dependencies
274-
run: dotnet restore
275-
working-directory: path/to/playwright/folder # update accordingly
276-
277-
- name: Build
278-
run: dotnet build --no-restore
279-
working-directory: path/to/playwright/folder # update accordingly
280-
281-
- name: Run Playwright tests
243+
on:
244+
push:
245+
branches: [ main, master ]
246+
pull_request:
247+
branches: [ main, master ]
248+
permissions: # Required when using AuthType as EntraId
249+
id-token: write
250+
contents: read
251+
jobs:
252+
test:
253+
timeout-minutes: 60
254+
runs-on: ubuntu-latest
255+
steps:
256+
- uses: actions/checkout@v4
257+
# This step is to sign-in to Azure to run tests from GitHub Action workflow.
258+
# Choose how to set up authentication to Azure from GitHub Actions. This is one example.
259+
260+
- name: Login to Azure with AzPowershell (enableAzPSSession true)
261+
uses: azure/login@v2
262+
with:
263+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
264+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
265+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
266+
enable-AzPSSession: true
267+
268+
- name: Setup .NET
269+
uses: actions/setup-dotnet@v4
270+
with:
271+
dotnet-version: 8.0.x
272+
273+
- name: Restore dependencies
274+
run: dotnet restore
282275
working-directory: path/to/playwright/folder # update accordingly
283-
env:
284-
# Regional endpoint for Microsoft Playwright Testing
285-
PLAYWRIGHT_SERVICE_URL: ${{ secrets.PLAYWRIGHT_SERVICE_URL }}
286-
PLAYWRIGHT_SERVICE_RUN_ID: ${{ github.run_id }}-${{ github.run_attempt }}-${{ github.sha }}
287-
run: dotnet test --settings:.runsettings --logger "microsoft-playwright-testing" -- NUnit.NumberOfTestWorkers=20
288-
289-
- name: Upload Playwright report
290-
uses: actions/upload-artifact@v3
291-
if: always()
292-
with:
293-
name: playwright-report
294-
path: path/to/playwright/folder/playwright-report/ # update accordingly
295-
retention-days: 10
276+
277+
- name: Build
278+
run: dotnet build --no-restore
279+
working-directory: path/to/playwright/folder # update accordingly
280+
281+
- name: Run Playwright tests
282+
working-directory: path/to/playwright/folder # update accordingly
283+
env:
284+
# Regional endpoint for Microsoft Playwright Testing
285+
PLAYWRIGHT_SERVICE_URL: ${{ secrets.PLAYWRIGHT_SERVICE_URL }}
286+
PLAYWRIGHT_SERVICE_RUN_ID: ${{ github.run_id }}-${{ github.run_attempt }}-${{ github.sha }}
287+
run: dotnet test --settings:.runsettings --logger "microsoft-playwright-testing" -- NUnit.NumberOfTestWorkers=20
288+
289+
- name: Upload Playwright report
290+
uses: actions/upload-artifact@v3
291+
if: always()
292+
with:
293+
name: playwright-report
294+
path: path/to/playwright/folder/playwright-report/ # update accordingly
295+
retention-days: 10
296296
```
297297

298298
# [Azure Pipelines](#tab/pipelines)

0 commit comments

Comments
 (0)