Repository navigation
[java] Add expected failure annotation - #18381
devisri468 wants to merge 2 commits into
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
36802a2 to
57d05c4
Compare
57d05c4 to
7bf076c
Compare
| return false; | ||
| } | ||
|
|
||
| String currentVersion = System.getProperty("selenium.browser.version", "").trim(); |
There was a problem hiding this comment.
selenium.browser.version is not set anywhere. selenium_test.bzl only passes -Dselenium.browser. So any minVersion or maxVersion never matches in a real run.
| throws Throwable { | ||
| // ExpectedFailureRule | ||
| if (ExpectedFailureMatcher.matches(context)) { | ||
| failedWithExpectedFailure = true; |
There was a problem hiding this comment.
This swallows every Throwable when the annotation matches, including a failed assumeThat. A skipped test gets reported as passed.
|
|
||
| package org.openqa.selenium.testing; | ||
|
|
||
| import java.lang.reflect.AnnotatedElement; |
There was a problem hiding this comment.
google-java-format changes this file. AnnotatedElement and Optional are unused, and the two findRepeatableAnnotations lines are over 100 chars.
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class ExpectedFailureTest { |
There was a problem hiding this comment.
Tests only cover compareVersions and browser matching. No coverage for minVersion / maxVersion, platform mismatch, repeated or class-level annotations, or the SeleniumExtension flow.
| public @interface ExpectedFailure { | ||
| Browser[] value() default {Browser.ALL}; | ||
|
|
||
| Browser[] browsers() default {}; |
There was a problem hiding this comment.
value and browsers do the same thing. If both are set, value is silently ignored.
| Optional<Method> testMethod = context.getTestMethod(); | ||
| throw new Exception( | ||
| String.format( | ||
| "%s.%s matched @ExpectedFailure but already works!", |
There was a problem hiding this comment.
Message does not say which browser matched, or the reason / issue from the annotation. The @NotYetImplemented message below includes the browser.
|
|
||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ElementType.METHOD, ElementType.TYPE}) | ||
| public @interface ExpectedFailures { |
There was a problem hiding this comment.
Other containers here use the List suffix: IgnoreList, NotYetImplementedList, NotWorkingInRemoteBazelBuildsList.
Related issue
#17428
What does this PR do?
Adds a repeatable Java
@ExpectedFailureannotation for expected browser-specific test failures. It supports browser, platform, and optional version constraints, and integrates withSeleniumExtensionso a matching failure is allowed while a matching test that passes unexpectedly fails.Tests
bazel test //java/test/org/openqa/selenium/testing:SmallTests --test_output=all— passed locally.AI assistance
GitHub Copilot assisted with implementation and test drafting. I reviewed the changes and understand the implementation.