diff --git a/ReactAndroid/src/main/third-party/java/robolectric/4.4/BUCK b/ReactAndroid/src/main/third-party/java/robolectric/4.4/BUCK index 9033f5b0ce9..92c97fbfdd3 100644 --- a/ReactAndroid/src/main/third-party/java/robolectric/4.4/BUCK +++ b/ReactAndroid/src/main/third-party/java/robolectric/4.4/BUCK @@ -5,7 +5,7 @@ rn_android_library( name = "robolectric", visibility = ["PUBLIC"], exported_deps = [ - ":android-all-4.1.2_r1-robolectric-r1", + ":android-all-5.0.2_r3-robolectric-r0", ":bouncycastle", ":guava", ":javax-annotation-api", @@ -28,8 +28,9 @@ rn_android_library( ], ) +# This is based on the minimum SDK version for tests: 21. rn_prebuilt_jar( - name = "android-all-4.1.2_r1-robolectric-r1", # name defines filename used by robolectric in runtime + name = "android-all-5.0.2_r3-robolectric-r0", # name defines filename used by robolectric in runtime binary_jar = ":robolectric-android-all-binary.jar", visibility = ["//ReactAndroid/..."], ) @@ -39,13 +40,13 @@ rn_prebuilt_jar( fb_native.export_file( name = "robolectric-android-all-binary.jar", src = ":robolectric-android-all-binary-remote.jar", - out = "../android-all-4.1.2_r1-robolectric-r1.jar", # name defines filename used by robolectric in runtime + out = "../android-all-5.0.2_r3-robolectric-r0.jar", # name defines filename used by robolectric in runtime ) fb_native.remote_file( name = "robolectric-android-all-binary-remote.jar", - sha1 = "8355a2da59fe0233ca45070ca32f08da98d0b806", - url = "mvn:org.robolectric:android-all:jar:4.1.2_r1-robolectric-r1", + sha1 = "ae6e8f47f73ffe34054852d9c7f4f4ec489254f1", + url = "mvn:org.robolectric:android-all:jar:5.0.2_r3-robolectric-r0", ) rn_prebuilt_jar( diff --git a/ReactAndroid/src/test/resources/BUCK b/ReactAndroid/src/test/resources/BUCK new file mode 100644 index 00000000000..af94e7bada4 --- /dev/null +++ b/ReactAndroid/src/test/resources/BUCK @@ -0,0 +1,17 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +java_library( + name = "robolectric", + srcs = [], + labels = [ + "supermodule:xplat/default/public.react_native.infra", + ], + resources = [ + "robolectric.properties", + ], + resources_root = ".", + visibility = ["PUBLIC"], +) diff --git a/ReactAndroid/src/test/resources/robolectric.properties b/ReactAndroid/src/test/resources/robolectric.properties new file mode 100644 index 00000000000..b0d79302d02 --- /dev/null +++ b/ReactAndroid/src/test/resources/robolectric.properties @@ -0,0 +1,2 @@ +# Set this to minimum supported API level for React Native. +sdk=21 diff --git a/tools/build_defs/oss/rn_defs.bzl b/tools/build_defs/oss/rn_defs.bzl index 42bafe6335f..c255f62bc0e 100644 --- a/tools/build_defs/oss/rn_defs.bzl +++ b/tools/build_defs/oss/rn_defs.bzl @@ -217,8 +217,9 @@ def rn_robolectric_test(name, srcs, vm_args = None, *args, **kwargs): kwargs["deps"] = kwargs.pop("deps", []) + [ react_native_android_toplevel_dep("third-party/java/mockito2:mockito2"), - react_native_xplat_dep("libraries/fbcore/src/test/java/com/facebook/powermock:powermock2"), react_native_dep("third-party/java/robolectric/4.4:robolectric"), + react_native_tests_target("resources:robolectric"), + react_native_xplat_dep("libraries/fbcore/src/test/java/com/facebook/powermock:powermock2"), ] extra_vm_args = [