Skip to content

[Bug]: Playwright-Junit lifecycle incompatible with maven retries 'surefire.rerunFailingTestsCount' #1751

@rtretyak

Description

@rtretyak

Version

1.50.0

Steps to reproduce

  1. Have a basic Playwright test that fails
  2. Try running it with maven retries: ./mvnw test -Dtest=MyTest -Dsurefire.rerunFailingTestsCount=2

Expected behavior

System is able to retry the failing test, system can work with Playwright context (browser, page etc.)

Actual behavior

First attempt is a legit failure, subsequent rerun attempts have broken Playwright context

[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.002 s <<< FAILURE! -- in fm.seller.onboardingweb.test.MyTest
[ERROR] fm.seller.onboardingweb.test.MyTest.test(Page) -- Time elapsed: 0.001 s <<< ERROR!
org.junit.jupiter.api.extension.ParameterResolutionException: Failed to resolve parameter [com.microsoft.playwright.Page page] in method [public void fm.seller.onboardingweb.test.MyTest.test(com.microsoft.playwright.Page)]: Playwright connection closed
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: com.microsoft.playwright.PlaywrightException: Playwright connection closed
        at com.microsoft.playwright.impl.PipeTransport.send(PipeTransport.java:50)
        at com.microsoft.playwright.impl.Connection.internalSendMessage(Connection.java:168)
        at com.microsoft.playwright.impl.Connection.sendMessageAsync(Connection.java:134)
        at com.microsoft.playwright.impl.ChannelOwner.sendMessageAsync(ChannelOwner.java:109)
        at com.microsoft.playwright.impl.SelectorsImpl.setTestIdAttributeName(SelectorsImpl.java:42)
        at com.microsoft.playwright.impl.SharedSelectors.lambda$setTestIdAttribute$2(SharedSelectors.java:72)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at com.microsoft.playwright.impl.SharedSelectors.setTestIdAttribute(SharedSelectors.java:72)
        at com.microsoft.playwright.impl.junit.ExtensionUtils.setTestIdAttribute(ExtensionUtils.java:53)
        at com.microsoft.playwright.impl.junit.BrowserContextExtension.getOrCreateBrowserContext(BrowserContextExtension.java:60)
        at com.microsoft.playwright.impl.junit.PageExtension.getOrCreatePage(PageExtension.java:51)
        at com.microsoft.playwright.impl.junit.PageExtension.resolveParameter(PageExtension.java:35)
        ... 2 more
[ERROR] Errors: 
[ERROR] fm.seller.onboardingweb.test.MyTest.test(Page)
[ERROR]   Run 1: MyTest.test:13
[ERROR]   Run 2: MyTest.test(Page) » ParameterResolution Failed to resolve parameter [com.microsoft.playwright.Page page] in method [public void fm.seller.onboardingweb.test.MyTest.test(com.microsoft.playwright.Page)]: Playwright connection closed
[ERROR]   Run 3: MyTest.test(Page) » ParameterResolution Failed to resolve parameter [com.microsoft.playwright.Page page] in method [public void fm.seller.onboardingweb.test.MyTest.test(com.microsoft.playwright.Page)]: Playwright connection closed

Additional context

Minimal test:

@UsePlaywright(OptionsFactory.class)
public class MyTest {
    @Test
    public void test(Page page) {
        page.navigate("https://google.com/");
        assert false;
    }
}

Environment

  • OS name: "mac os x", version: "15.3", arch: "aarch64", family: "mac"
  • Java version: 17.0.2, vendor: Oracle Corporation
  • Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
  • playwright 1.50.0
  • Junit 5.11.4
  • surefire 3.5.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions