Skip to content

[java] Add expected failure annotation - #18381

Open
devisri468 wants to merge 2 commits into
SeleniumHQ:trunkfrom
devisri468:java-expected-failure-17428
Open

devisri468 wants to merge 2 commits into
SeleniumHQ:trunkfrom
devisri468:java-expected-failure-17428

Conversation

@devisri468

@devisri468 devisri468 commented Nov 24, 2026 •

Copy link
Copy Markdown

Related issue

#17428

What does this PR do?

Adds a repeatable Java @ExpectedFailure annotation for expected browser-specific test failures. It supports browser, platform, and optional version constraints, and integrates with SeleniumExtension so 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.

@CLAassistant

CLAassistant commented Nov 24, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@selenium-ci selenium-ci added C-java Java Bindings B-build Includes scripting, bazel and CI integrations labels Nov 24, 2026
@devisri468
devisri468 force-pushed the java-expected-failure-17428 branch from 36802a2 to 57d05c4 Compare November 24, 2026 15:36
@devisri468
devisri468 force-pushed the java-expected-failure-17428 branch from 57d05c4 to 7bf076c Compare November 24, 2026 15:48
return false;
}

String currentVersion = System.getProperty("selenium.browser.version", "").trim();

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.

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;

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 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;

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.

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 {

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.

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 {};

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.

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!",

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.

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 {

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.

Other containers here use the List suffix: IgnoreList, NotYetImplementedList, NotWorkingInRemoteBazelBuildsList.

This branch has not been deployed

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

Labels

B-build Includes scripting, bazel and CI integrations C-java Java Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants