-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Move scanActualColors to JupiterTestBase and remove duplicates #16553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
Extract scanActualColors(BufferedImage, int, int) into the test base class JupiterTestBase and remove duplicate implementations from TakesScreenshotTest and org.openqa.selenium.firefox.TakesFullPageScreenshotTest. This centralizes the utility used by screenshot tests so subclasses reuse a single, well-documented implementation and reduces code duplication. Adjusted imports and replaced the local implementations with a short comment pointing to the base method.
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||
Delta456
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the need to move it to JupiterTestbase 🤔
cgoldberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the point of this PR is to consolidate and remove duplicate code, the rest of the duplicate screenshot-related methods in ./firefox/TakesFullPageScreenshotTest.java should also be moved. It makes no sense to just move one method while leaving the others.
Also, JupiterTestBase.java contains no other similar helper methods. These should go in ./testing/TestUtilities.java or in its own class/file under ./testing/.
You're absolutely right — I also noticed there are several other duplicated screenshot-related methods. Before moving forward and removing more of that duplicated code, I wanted to make sure the team agrees with this approach. My goal with this PR was to start small and keep the changes easy to review, rather than submitting a large PR affecting multiple classes at once. Once there's alignment on this direction, I can continue cleaning up the remaining duplicated methods in subsequent PRs. |
I don’t really keep track of which of my PRs were accepted or not — I contribute because I believe in the project, not to waste anyone’s time. I honestly don’t understand the need for such a passive-aggressive message. Is this meant as an invitation for me to stop contributing? I don’t think this is the right way to respond to a PR. Maybe my proposed improvement isn’t good enough for you, but I did it with the best intentions and genuine willingness to help the project move forward. |
The screenshot-related methods are all related and small. Just add them to a single PR. |
User description
What does this PR do?
Moves the shared test utility
scanActualColors(BufferedImage, int, int)toJupiterTestBaseand deletes the duplicate implementations in:org.openqa.selenium.TakesScreenshotTestorg.openqa.selenium.firefox.TakesFullPageScreenshotTestCentralizing this logic removes duplication, makes maintenance easier, and ensures all screenshot tests rely on the same well-documented implementation.
Why?
JupiterTestBase) where other JUnit 5 tests can reuse them.How (Implementation Notes)
protected final Set<String> scanActualColors(BufferedImage image, int stepX, int stepY)toJupiterTestBase.Tests
Types of changes
Risks & Trade-offs
protected+finalto encourage reuse while preventing overrides that could fragment behavior across tests.Follow-ups (optional)
stepX > 0,stepY > 0) and a short doc comment on sampling strategy.PR Type
Enhancement
Description
Centralizes
scanActualColors()utility method inJupiterTestBaseRemoves duplicate implementations from two test classes
Reduces code duplication and improves maintainability
Method marked
protected finalto encourage reuse while preventing overridesDiagram Walkthrough
File Walkthrough
TakesScreenshotTest.java
Remove duplicate scanActualColors methodjava/test/org/openqa/selenium/TakesScreenshotTest.java
scanActualColors()method (38 lines)JupiterTestBaseTakesFullPageScreenshotTest.java
Remove duplicate scanActualColors and clean importsjava/test/org/openqa/selenium/firefox/TakesFullPageScreenshotTest.java
scanActualColors()method (38 lines)RasterimportJupiterTestBaseJupiterTestBase.java
Add shared scanActualColors utility methodjava/test/org/openqa/selenium/testing/JupiterTestBase.java
protected final scanActualColors()method with fullimplementation
BufferedImage,Raster,Set,TreeSet,assertThat,fail