My feature branch#2630
Conversation
👷 Deploy request for selenium-dev pending review.Visit the deploys page to approve it
|
|
|
Review Summary by QodoComprehensive JUnit 5 and Selenium Test Examples with Maven Dependencies Update
WalkthroughsDescription• Added comprehensive JUnit 5 test examples covering parameterized tests, dynamic tests, conditional execution, assertions, temporary directories, and launcher API usage • Added extensive Selenium test examples demonstrating support classes, synchronization strategies, page objects, element abstractions, and advanced GUI patterns • Added Selenium training examples covering keyboard input, scrolling, window switching, alerts, and drag-and-drop operations • Updated Maven dependencies with JUnit Jupiter 5.10.3, JUnit Platform 1.10.1, and additional testing libraries (junit-platform-runner, webdrivermanager, hamcrest, jimfs, javafaker, cucumber-java, testng, selenium-jupiter) • Downgraded Selenium version from 4.41.0 to 4.22.0 • Added JUnit 5 reference documentation and study notes covering Maven/Gradle commands, display names, assertions, parameterized tests, dynamic tests, timeouts, and parallel execution • Added domain model classes and utility classes for test infrastructure • Implemented JUnit 5 extensions for random number injection, timing measurement, and error state recording • Added custom launcher interceptor and test kit demonstrations Diagramflowchart LR
A["Maven pom.xml"] -- "adds JUnit 5 & test dependencies" --> B["JUnit 5 Test Examples"]
A -- "adds Selenium & support libraries" --> C["Selenium Test Examples"]
B -- "demonstrates" --> D["Parameterized Tests"]
B -- "demonstrates" --> E["Dynamic Tests"]
B -- "demonstrates" --> F["Conditional Execution"]
B -- "demonstrates" --> G["Extensions & Callbacks"]
C -- "demonstrates" --> H["Support Classes"]
C -- "demonstrates" --> I["Synchronization Strategies"]
C -- "demonstrates" --> J["Page Objects"]
C -- "demonstrates" --> K["Element Abstractions"]
L["Documentation Files"] -- "provides reference" --> B
L -- "provides reference" --> C
File Changes1. examples/java/src/test/java/junit5/example/ParameterizedTestDemo.java
|
Code Review by Qodo
1. Always-failing JUnit tests
|
917e62f to
13e0592
Compare
| @Test | ||
| void failingTest() { | ||
| fail("a failing test"); | ||
| } |
There was a problem hiding this comment.
1. Always-failing junit tests 🐞 Bug ≡ Correctness
junit5.example.J1StandardTests#failingTest() unconditionally calls fail(), and junit5.example.ExampleTestCase#failingTest() triggers an unchecked divide-by-zero via calculator.divide(1, 0). Since the repo CI workflow runs mvn test for changes under examples/java/**, these tests will fail the PR's Java examples workflow.
Agent Prompt
### Issue description
Two newly added test classes that match Surefire’s default include patterns contain intentional failures. This makes `mvn test` fail in CI.
### Issue Context
These files appear copied from documentation examples, but they live in `src/test/java` with names that Surefire will execute (`*Tests.java`, `*TestCase.java`).
### Fix Focus Areas
- examples/java/src/test/java/junit5/example/J1StandardTests.java[41-57]
- examples/java/src/test/java/junit5/example/ExampleTestCase.java[49-56]
- .github/workflows/java-examples.yml[63-72]
### Suggested fix
Do one of:
1) Mark the failing methods/classes with `@Disabled`, or
2) Change the failing test to assert expected behavior (e.g., `assertThrows(ArithmeticException.class, () -> calculator.divide(1, 0))`), or
3) Rename/move these classes so they are not executed by Surefire in CI (preferred if they are docs-only snippets).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| package junit5.example; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||
| public class JUnit4Tests { | ||
|
|
||
| @Test | ||
| public void standardJUnit4Test() { |
There was a problem hiding this comment.
2. Junit4 dependency missing 🐞 Bug ≡ Correctness
New tests import JUnit 4 APIs (org.junit.Test / org.junit.runner.RunWith), but examples/java/pom.xml does not declare a JUnit 4 dependency. Maven test compilation will fail with missing org.junit.* types.
Agent Prompt
### Issue description
Test sources import JUnit 4 (`org.junit.*`) but the Maven module does not include a JUnit 4 dependency, causing test compilation to fail.
### Issue Context
These are docs-style examples that use the JUnit Platform runner integration (`@RunWith(JUnitPlatform.class)`). Even if you don’t intend to execute them, they must still compile.
### Fix Focus Areas
- examples/java/src/test/java/junit5/example/JUnit4Tests.java[11-20]
- examples/java/src/test/java/junit5/example/JUnitPlatformClassDemo.java[13-33]
- examples/java/src/test/java/junit5/example/JUnitPlatformSuiteDemo.java[13-23]
- examples/java/pom.xml[35-172]
### Suggested fix
Add a JUnit 4 dependency (test scope) in `examples/java/pom.xml`, e.g. `junit:junit`.
Optionally, if you want these JUnit 4 tests to *run* on the JUnit Platform, add the Vintage engine as well; otherwise, keep them compile-only (or rename/move them).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| <maven.compiler.source>17</maven.compiler.source> | ||
| <maven.compiler.target>17</maven.compiler.target> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <selenium.version>4.41.0</selenium.version> | ||
| <selenium.version>4.22.0</selenium.version> | ||
| <junit-jupiter>5.10.3</junit-jupiter> | ||
| <junit-platform>1.10.1</junit-platform> |
There was a problem hiding this comment.
3. Selenium version downgraded 🐞 Bug ☼ Reliability
examples/java/pom.xml downgrades selenium.version from 4.41.0 to 4.22.0. The CI workflow’s nightly job derives a X.(Y+1).0-SNAPSHOT from this property, so this change makes nightly CI test a different, older snapshot track and diverges from other example modules.
Agent Prompt
### Issue description
The Java examples module was downgraded to an older Selenium version, which changes which SNAPSHOT gets tested in nightly CI and makes the Java examples inconsistent with Kotlin examples.
### Issue Context
Nightly CI computes `new_version="$major.$((minor+1)).0-SNAPSHOT"` based on the `selenium.version` property.
### Fix Focus Areas
- examples/java/pom.xml[11-19]
- .github/workflows/java-examples.yml[88-100]
- examples/kotlin/pom.xml[20-23]
### Suggested fix
Revert `examples/java/pom.xml` to the current Selenium version used elsewhere in the repo (e.g., align with `examples/kotlin/pom.xml`), so nightly tests the intended next-minor snapshot and examples stay consistent.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Thanks for contributing to the Selenium site and documentation!
A PR well described will help maintainers to review and merge it quickly
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, and help reviewers by making them as simple and short as possible.
Description
Motivation and Context
Types of changes
Checklist