Skip to content

Commit 72ac24b

Browse files
committed
added NUnit quickstart
1 parent 5427cf5 commit 72ac24b

File tree

1 file changed

+65
-4
lines changed

1 file changed

+65
-4
lines changed

articles/playwright-testing/quickstart-run-end-to-end-tests.md

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ To get the service endpoint URL, perform the following steps:
7070

7171
1. In **Add region endpoint in your setup**, copy the region endpoint for your workspace.
7272

73-
The endpoint URL matches the Azure region that you selected when creating the workspace.
73+
The endpoint URL matches the Azure region that you selected when creating the workspace. Make sure this URL is available in `PLAYWRIGHT_SERVICE_URL` environment variable.
7474

7575
:::image type="content" source="./media/quickstart-run-end-to-end-tests/playwright-testing-region-endpoint.png" alt-text="Screenshot that shows how to copy the workspace region endpoint in the Playwright Testing portal." lightbox="./media/quickstart-run-end-to-end-tests/playwright-testing-region-endpoint.png":::
7676

77+
::: zone pivot="playwright-test-runner"
78+
7779
## Set up your environment
7880

7981
To set up your environment, you have to configure the `PLAYWRIGHT_SERVICE_URL` environment variable with the value you obtained in the previous steps.
@@ -94,7 +96,26 @@ We recommend that you use the `dotenv` module to manage your environment. With `
9496

9597
Make sure to replace the `{MY-REGION-ENDPOINT}` text placeholder with the value you copied earlier.
9698

99+
::: zone-end
100+
101+
::: zone pivot="nunit-test-runner"
102+
## Set up service configuration
103+
104+
Create a file `PlaywrightServiceSetup.cs` in the root directory with the following content.
105+
106+
```csharp
107+
using Azure.Developer.MicrosoftPlaywrightTesting.NUnit;
108+
109+
namespace PlaywrightTests; // Remember to change this as per your project namespace
110+
111+
[SetUpFixture]
112+
public class PlaywrightServiceSetup : PlaywrightServiceNUnit {};
113+
```
97114

115+
> [!NOTE]
116+
> Make sure your project uses `Microsoft.Playwright.NUnit` version 1.47 or above.
117+
118+
::: zone-end
98119
## Set up Authentication
99120

100121
To run your Playwright tests in your Microsoft Playwright Testing workspace, you need to authenticate the Playwright client where you're running the tests with the service. This could be your local dev machine or CI machine.
@@ -124,7 +145,10 @@ You can generate an access token from your Playwright Testing workspace and use
124145
> [!CAUTION]
125146
> We strongly recommend using Microsoft Entra ID for authentication to the service. If you are using access tokens, see [How to Manage Access Tokens](./how-to-manage-access-tokens.md)
126147

148+
127149
## Enable artifacts in Playwright configuration
150+
::: zone pivot="playwright-test-runner"
151+
128152
In the `playwright.config.ts` file of your project, make sure you are collecting all the required artifacts.
129153
```typescript
130154
use: {
@@ -133,11 +157,23 @@ In the `playwright.config.ts` file of your project, make sure you are collecting
133157
screenshot:'on'
134158
}
135159
```
136-
## Run your tests at scale with Microsoft Playwright Testing
160+
::: zone-end
161+
162+
::: zone pivot="nunit-test-runner"
163+
164+
Enable artifacts such as screenshot, videos and traces to be captured by Playwright.
165+
- For screenshots, see [capture screenshots](https://playwright.dev/dotnet/docs/screenshots#introduction)
166+
- For videos, see [record videos for your tests](https://playwright.dev/dotnet/docs/videos#introduction)
167+
- For traces, see [recording a trace](https://playwright.dev/dotnet/docs/trace-viewer-intro#recording-a-trace)
168+
::: zone-end
169+
170+
## Run your tests at scale and troubleshoot easily with Microsoft Playwright Testing
171+
172+
::: zone pivot="playwright-test-runner"
137173

138174
You've now prepared the configuration for running your Playwright tests in the cloud with Microsoft Playwright Testing. You can either use the Playwright CLI to run your tests, or use the [Playwright Test Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright).
139175
140-
### Run a single test at scale
176+
### Run a single test with the service
141177
142178
With Microsoft Playwright Testing, you get charged based on the number of total test minutes and number of test results published. If you're a first-time user or [getting started with a free trial](./how-to-try-playwright-testing-free.md), you might start with running a single test at scale instead of your full test suite to avoid exhausting your free trial limits.
143179

@@ -213,7 +249,7 @@ You can now run multiple tests with the service, or run your entire test suite o
213249
> [!CAUTION]
214250
> Depending on the size of your test suite, you might incur additional charges for the test minutes and test results beyond your allotted free test minutes and free test results.
215251

216-
### Run a full test suite at scale
252+
### Run a full test suite with the service
217253

218254
Now that you've validated that you can run a single test with Microsoft Playwright Testing, you can run a full Playwright test suite at scale.
219255
@@ -264,6 +300,31 @@ To run your Playwright test suite in Visual Studio Code with Microsoft Playwrigh
264300
1. You can view all test results in the **Test results** tab.
265301
266302
---
303+
::: zone-end
304+
305+
::: zone pivot="nunit-test-runner"
306+
307+
Run Playwright tests against browsers managed by the service and see the results in the unified portal using the configuration you created above.
308+
309+
```bash
310+
dotnet test --logger "microsoft-playwright-testing"
311+
```
312+
After the test run completes, you can view the test status in the terminal..
313+
314+
```output
315+
Starting test execution, please wait...
316+
317+
Initializing reporting for this test run. You can view the results at: https://playwright.microsoft.com/workspaces/<workspace-id>/runs/<run-id>
318+
319+
A total of 100 test files matched the specified pattern.
320+
321+
Test Report: https://playwright.microsoft.com/workspaces/<workspace-id>/runs/<run-id>
322+
323+
Passed! - Failed: 0, Passed: 100, Skipped: 0, Total: 100, Duration: 59 s - PlaywrightTestsNUnit.dll (net7.0)
324+
325+
Workload updates are available. Run `dotnet workload list` for more information.
326+
```
327+
::: zone-end
267328
268329
## View test runs and results in the Playwright portal
269330

0 commit comments

Comments
 (0)