Skip to content

Commit 9850c95

Browse files
authored
[java] Fix test ignorance custom logic (#11007)
1 parent c063709 commit 9850c95

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

java/test/org/openqa/selenium/CookieImplementationTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,7 @@ public void testAddCookiesWithDifferentPathsThatAreRelatedToOurs() {
203203

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

425422
@Test
426423
@Ignore(SAFARI)
427-
@NotYetImplemented(CHROME)
428424
public void canHandleHttpOnlyCookie() {
429425
Cookie addedCookie =
430426
new Cookie.Builder("fish", "cod")

java/test/org/openqa/selenium/testing/IgnoreComparator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public boolean shouldIgnore(Ignore ignore) {
4545
return ignore != null && shouldIgnore(Stream.of(ignore));
4646
}
4747

48-
private boolean shouldIgnore(Stream<Ignore> ignoreList) {
48+
public boolean shouldIgnore(Stream<Ignore> ignoreList) {
4949
return ignoreList.anyMatch(
5050
driver -> (ignored.contains(driver.value()) || driver.value() == Browser.ALL)
5151
&& ((!driver.travis() || TestUtilities.isOnTravis())

java/test/org/openqa/selenium/testing/TestIgnorance.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.lang.reflect.Method;
2626
import java.util.Arrays;
2727
import java.util.HashSet;
28+
import java.util.List;
2829
import java.util.Optional;
2930
import java.util.Set;
3031

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

7475
// Ignored because of Selenium's custom extensions
75-
boolean ignored = findAnnotation(testClass, IgnoreList.class).isPresent() ||
76-
!findRepeatableAnnotations(testClass, Ignore.class).isEmpty() ||
77-
findAnnotation(testMethod, IgnoreList.class).isPresent() ||
78-
!findRepeatableAnnotations(testMethod, Ignore.class).isEmpty();
76+
Optional<IgnoreList> ignoreListClass = findAnnotation(testClass, IgnoreList.class);
77+
List<Ignore> ignoreClass = findRepeatableAnnotations(testClass, Ignore.class);
78+
Optional<IgnoreList> ignoreListMethod = findAnnotation(testMethod, IgnoreList.class);
79+
List<Ignore> ignoreMethod = findRepeatableAnnotations(testMethod, Ignore.class);
80+
boolean ignored = (ignoreListClass.isPresent() && ignoreComparator.shouldIgnore(ignoreListClass.get())) ||
81+
(!ignoreClass.isEmpty() && ignoreComparator.shouldIgnore(ignoreClass.stream())) ||
82+
(ignoreListMethod.isPresent() && ignoreComparator.shouldIgnore(ignoreListMethod.get())) ||
83+
(!ignoreMethod.isEmpty() && ignoreComparator.shouldIgnore(ignoreMethod.stream()));
7984

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

0 commit comments

Comments
 (0)