Skip to content

docs: add Java version of Best Practices guide#40580

Open
Riya25maheshwari wants to merge 1 commit intomicrosoft:mainfrom
Riya25maheshwari:riya-java-best-practices
Open

docs: add Java version of Best Practices guide#40580
Riya25maheshwari wants to merge 1 commit intomicrosoft:mainfrom
Riya25maheshwari:riya-java-best-practices

Conversation

@Riya25maheshwari
Copy link
Copy Markdown

Adds docs/src/best-practices-java.md which was missing for Java while available for Node.js, Python, and .NET.

playwright.dev/java/docs/best-practices currently returns 404.

Translates all code examples to Java using Playwright Java API: JUnit 5 @Test/@beforeeach, AriaRole enums, assertThat assertions, Route.FulfillOptions, and Maven CLI commands.
Removes TypeScript/ESLint sections with no Java equivalent.

Adds docs/src/best-practices-java.md which was missing for Java
while available for Node.js, Python, and .NET.

playwright.dev/java/docs/best-practices currently returns 404.

Translates all code examples to Java using Playwright Java API:
JUnit 5 @Test/@beforeeach, AriaRole enums, assertThat assertions,
Route.FulfillOptions, and Maven CLI commands.
Removes TypeScript/ESLint sections with no Java equivalent.
@Riya25maheshwari
Copy link
Copy Markdown
Author

@Riya25maheshwari please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

Copy link
Copy Markdown
Member

@Skn0tt Skn0tt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thank you!


If your test fails, Playwright will give you an error message showing what part of the test failed which you can see either in the terminal, the trace viewer, or your CI output. However, you can also use soft assertions to not immediately terminate the test execution, but rather compile and display a list of failed assertions once the test ended.

Java Playwright does not have a built-in `expect.soft()` equivalent. You can achieve the same behavior using JUnit 5's `assertAll()`, which runs all supplied assertions and reports all failures together:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is worded as if there was a feature gap in Playwright Java, which is misleading and not good in a Best Practices guid. Let's reword it to make clear that the best practice is to use the JUnit feature:

Suggested change
Java Playwright does not have a built-in `expect.soft()` equivalent. You can achieve the same behavior using JUnit 5's `assertAll()`, which runs all supplied assertions and reports all failures together:
Use JUnit 5's `assertAll()`, which runs all supplied assertions and reports all failures together:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants