Skip to content
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

[java] Fix test ignorance custom logic #11007

Merged
merged 1 commit into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions java/test/org/openqa/selenium/CookieImplementationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,7 @@ public void testAddCookiesWithDifferentPathsThatAreRelatedToOurs() {

@SwitchToTopAfterTest
@Test
@NotYetImplemented(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=3153")
@NotYetImplemented(value = EDGE, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=3153")
@Ignore(SAFARI)
@NotYetImplemented(value = FIREFOX, reason = "https://github.com/mozilla/geckodriver/issues/1104")
public void testGetCookiesInAFrame() {
driver.get(domainHelper.getUrlForFirstValidHostname("/common/animals"));
Cookie cookie1 = new Cookie.Builder("fish", "cod").path("/common/animals").build();
Expand Down Expand Up @@ -424,7 +421,6 @@ public void testRetainsCookieSecure() {

@Test
@Ignore(SAFARI)
@NotYetImplemented(CHROME)
public void canHandleHttpOnlyCookie() {
Cookie addedCookie =
new Cookie.Builder("fish", "cod")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public boolean shouldIgnore(Ignore ignore) {
return ignore != null && shouldIgnore(Stream.of(ignore));
}

private boolean shouldIgnore(Stream<Ignore> ignoreList) {
public boolean shouldIgnore(Stream<Ignore> ignoreList) {
return ignoreList.anyMatch(
driver -> (ignored.contains(driver.value()) || driver.value() == Browser.ALL)
&& ((!driver.travis() || TestUtilities.isOnTravis())
Expand Down
13 changes: 9 additions & 4 deletions java/test/org/openqa/selenium/testing/TestIgnorance.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;

Expand Down Expand Up @@ -72,10 +73,14 @@ public boolean isIgnored(ExtensionContext extensionContext) {
Optional<Method> testMethod = extensionContext.getTestMethod();

// Ignored because of Selenium's custom extensions
boolean ignored = findAnnotation(testClass, IgnoreList.class).isPresent() ||
!findRepeatableAnnotations(testClass, Ignore.class).isEmpty() ||
findAnnotation(testMethod, IgnoreList.class).isPresent() ||
!findRepeatableAnnotations(testMethod, Ignore.class).isEmpty();
Optional<IgnoreList> ignoreListClass = findAnnotation(testClass, IgnoreList.class);
List<Ignore> ignoreClass = findRepeatableAnnotations(testClass, Ignore.class);
Optional<IgnoreList> ignoreListMethod = findAnnotation(testMethod, IgnoreList.class);
List<Ignore> ignoreMethod = findRepeatableAnnotations(testMethod, Ignore.class);
boolean ignored = (ignoreListClass.isPresent() && ignoreComparator.shouldIgnore(ignoreListClass.get())) ||
(!ignoreClass.isEmpty() && ignoreComparator.shouldIgnore(ignoreClass.stream())) ||
(ignoreListMethod.isPresent() && ignoreComparator.shouldIgnore(ignoreListMethod.get())) ||
(!ignoreMethod.isEmpty() && ignoreComparator.shouldIgnore(ignoreMethod.stream()));

// Ignored because of Jupiter's @Disabled
ignored |= findAnnotation(testClass, Disabled.class).isPresent();
Expand Down