Jelajahi Sumber

Make RTDB integration tests runnable on a real target (#9688)

Paul Beusterien 4 tahun lalu
induk
melakukan
aefb2a469b
2 mengubah file dengan 12 tambahan dan 1 penghapusan
  1. 1 0
      FirebaseDatabase.podspec
  2. 11 1
      FirebaseDatabase/Tests/Helpers/FTestBase.m

+ 1 - 0
FirebaseDatabase.podspec

@@ -78,6 +78,7 @@ Simplify your iOS development, grow your user base, and monetize more effectivel
   s.test_spec 'integration' do |int_tests|
     int_tests.platforms = {:ios => ios_deployment_target, :osx => osx_deployment_target, :tvos => tvos_deployment_target}
     int_tests.scheme = { :code_coverage => true }
+    int_tests.requires_app_host = true
     int_tests.source_files = [
       'FirebaseDatabase/Tests/Integration/*.[mh]',
       'FirebaseDatabase/Tests/Helpers/*.[mh]',

+ 11 - 1
FirebaseDatabase/Tests/Helpers/FTestBase.m

@@ -20,12 +20,22 @@
 #import "FirebaseDatabase/Tests/Helpers/FTestBase.h"
 #import "SharedTestUtilities/FIROptionsMock.h"
 
+@interface FIROptions (Testing)
++ (NSString *)plistFilePathWithName:(NSString *)fileName;
+@end
+
 @implementation FTestBase
 
 + (void)setUp {
   static dispatch_once_t once;
   dispatch_once(&once, ^{
-    [FIROptionsMock mockFIROptions];
+    if ([FIROptions plistFilePathWithName:@"GoogleService-Info"] == nil) {
+      // Mock options for unit tests and emulator runs.
+      // To run the integration tests with a real GoogleService-Info.plist, add the
+      // GoogleService-Info.plist file to the AppHost-FirebaseDatabase-Unit-Tests generated target
+      // in the Pods project created by `pod gen`.
+      [FIROptionsMock mockFIROptions];
+    }
     [FIRApp configure];
   });
 }