diff --git a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/ArrayTransformsTest.java b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/ArrayTransformsTest.java index 172dc1cdf01..09c59139214 100644 --- a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/ArrayTransformsTest.java +++ b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/ArrayTransformsTest.java @@ -27,6 +27,7 @@ import java.util.Map; import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -37,6 +38,9 @@ */ @RunWith(AndroidJUnit4.class) public class ArrayTransformsTest { + // TODO(b/114769487): These tests have been flaky in CI so temporarily retrying. + @Rule public RetryRule retryRule = new RetryRule(3); + // A document reference to read and write to. private DocumentReference docRef; diff --git a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/POJOTest.java b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/POJOTest.java index c75bc84f5ef..5e8c941f89f 100644 --- a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/POJOTest.java +++ b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/POJOTest.java @@ -29,7 +29,6 @@ @RunWith(AndroidJUnit4.class) public class POJOTest { - public static class POJO { double number; diff --git a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/RetryRule.java b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/RetryRule.java new file mode 100644 index 00000000000..c72801e74a3 --- /dev/null +++ b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/RetryRule.java @@ -0,0 +1,48 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.firebase.firestore; + +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +public class RetryRule implements TestRule { + private int retryCount; + + public RetryRule(int retryCount) { + this.retryCount = retryCount; + } + + public Statement apply(final Statement base, Description description) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + Throwable caughtThrowable = null; + + for (int i = 0; i < retryCount; i++) { + System.out.println("Trying...." + i); + try { + base.evaluate(); + return; + } catch (Throwable t) { + caughtThrowable = t; + } + } + + throw caughtThrowable; + } + }; + } +}