Skip to content

Commit

Permalink
[java] Fix test ignorance custom logic
Browse files Browse the repository at this point in the history
  • Loading branch information
bonigarcia committed Sep 5, 2022
1 parent 5050a6b commit 8b6eed2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
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

0 comments on commit 8b6eed2

Please sign in to comment.