-
Notifications
You must be signed in to change notification settings - Fork 249
Description
To provide decent support of JUnit in codegen (as requested in #1039), we need to first implement basic Playwright fixtures similar to other languages. This came up in the discussion of #1366 and whether/how we can integrate https://github.com/uchagani/junit-playwright into Playwright. Below are some of the requirements we'll have for such integration and some comments regarding how it compares to the existing junit-playwright.
The execution model should be similar to the default execution model of Node.js Playwright. I.e. it should be possible to
- configure browser options per test file, so that an instance of the browser is reused by all tests in the same file
- do not parallel tests in the same file, only run in parallel tests in different classes (files), i.e. in terms of junit config:
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = same_thread
junit.jupiter.execution.parallel.mode.classes.default = concurrent
Builtin fixtures should create Playwright, Browser, BrowserContext and Page. Their lifetimes should match those in Node.js version, i.e.
- new context and page are created before each test
- for each test, same instance of page and context is used within the test, @beforeeach and @afterEach hooks
- page and context are closed right after last @afterEach hook finished for the test
Browser & playwright lifetimes should be bound to the thread & browser configuration. Playwright instance most likely should be thread local and can be reused by all tests running on that thread. We should try to reuse the same browser instance for running more tests that require the browser launch options. Currently, playwright internal test suite creates new browser per test class which seems to be good enough.
To keep things simple in the beginning we'd like to replace PlaywrightBrowserConfig with a configurable BrowserFactory, so that we don't have to think about config format and let the user create custom browser themselves. Eventually, we'll likely want to load the config from a json/xml/.properties file. We'll likely need to experiment with a few approaches here, to strike a balance.