Skip to content

Commit

Permalink
Migrate react-native Android tests to Robolectric v4 (#28927)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #28927

Changelog:
[Android] [Changed] Test Modernization

Reviewed By: mdvacca

Differential Revision: D21598788

fbshipit-source-id: 6fd9c30220d6d69cc68f13bf1f5ad5a4bc2b039a
  • Loading branch information
Joshua Selbo authored and facebook-github-bot committed May 27, 2020
1 parent 6f75065 commit 6a78b32
Show file tree
Hide file tree
Showing 27 changed files with 460 additions and 334 deletions.
2 changes: 1 addition & 1 deletion ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ dependencies {
extractJNI("com.facebook.fbjni:fbjni:0.0.2")

testImplementation("junit:junit:${JUNIT_VERSION}")
testImplementation("org.powermock:powermock-api-mockito:${POWERMOCK_VERSION}")
testImplementation("org.powermock:powermock-api-mockito2:${POWERMOCK_VERSION}")
testImplementation("org.powermock:powermock-module-junit4-rule:${POWERMOCK_VERSION}")
testImplementation("org.powermock:powermock-classloading-xstream:${POWERMOCK_VERSION}")
testImplementation("org.mockito:mockito-core:${MOCKITO_CORE_VERSION}")
Expand Down
6 changes: 3 additions & 3 deletions ReactAndroid/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ POM_NAME=ReactNative
POM_ARTIFACT_ID=react-native
POM_PACKAGING=aar

MOCKITO_CORE_VERSION=2.19.1
POWERMOCK_VERSION=1.6.2
ROBOLECTRIC_VERSION=3.0
MOCKITO_CORE_VERSION=2.26.0
POWERMOCK_VERSION=2.0.2
ROBOLECTRIC_VERSION=4.3.1
JUNIT_VERSION=4.12
FEST_ASSERT_CORE_VERSION=2.0M10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,164 +2,174 @@ load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_jar")

rn_android_library(
name = "powermock",
visibility = ["//ReactAndroid/..."],
name = "powermock2",
visibility = ["PUBLIC"],
exported_deps = [
":javassist",
":mockito-all",
":powermock-api-mockito",
":javassist-prebuilt",
":powermock-api-mockito2",
":powermock-api-support",
":powermock-classloading-base",
":powermock-classloading-xstream",
":powermock-classloading-xstream-prebuilt",
":powermock-core",
":powermock-module-junit4-rule",
":powermock-module-junit-common-prebuilt",
":powermock-module-junit-rule-prebuilt",
":powermock-reflect",
":xmlpull",
":xpp3",
":xstream",
":xstream-prebuilt",
],
)

rn_android_library(
name = "powermock-reflect",
visibility = ["PUBLIC"],
exported_deps = [
":byte-buddy",
":objenesis",
":powermock-reflect-prebuilt",
],
)

rn_prebuilt_jar(
name = "powermock-core",
binary_jar = ":download-powermock-core.jar",
name = "byte-buddy",
binary_jar = ":byte-buddy-binary.jar",
visibility = ["//ReactAndroid/..."],
)

fb_native.remote_file(
name = "download-powermock-core.jar",
sha1 = "ea04e79244e19dcf0c3ccf6863c5b028b4b58c9c",
url = "mvn:org.powermock:powermock-core:jar:1.6.2",
name = "byte-buddy-binary.jar",
sha1 = "211a2b4d3df1eeef2a6cacf78d74a1f725e7a840",
url = "mvn:net.bytebuddy:byte-buddy:jar:1.9.10",
)

rn_prebuilt_jar(
name = "powermock-api-mockito",
binary_jar = ":download-powermock-api-mockito.jar",
name = "byte-buddy-agent",
binary_jar = ":byte-buddy-agent-binary.jar",
visibility = ["//ReactAndroid/..."],
)

fb_native.remote_file(
name = "download-powermock-api-mockito.jar",
sha1 = "c213230ae20a7b422f3d622a261d0e3427d2464c",
url = "mvn:org.powermock:powermock-api-mockito:jar:1.6.2",
name = "byte-buddy-agent-binary.jar",
sha1 = "9674aba5ee793e54b864952b001166848da0f26b",
url = "mvn:net.bytebuddy:byte-buddy-agent:jar:1.9.10",
)

rn_prebuilt_jar(
name = "powermock-api-support",
binary_jar = ":download-powermock-api-support.jar",
name = "objenesis",
binary_jar = ":objenesis-binary.jar",
visibility = ["//ReactAndroid/..."],
)

fb_native.remote_file(
name = "download-powermock-api-support.jar",
sha1 = "93b21413b4ee99b7bc0dd34e1416fdca96866aaf",
url = "mvn:org.powermock:powermock-api-support:jar:1.6.2",
name = "objenesis-binary.jar",
sha1 = "639033469776fd37c08358c6b92a4761feb2af4b",
url = "mvn:org.objenesis:objenesis:jar:2.6",
)

rn_prebuilt_jar(
name = "powermock-module-junit4-rule",
binary_jar = ":download-powermock-module-junit4-rule.jar",
visibility = ["//ReactAndroid/..."],
name = "powermock-reflect-prebuilt",
binary_jar = ":powermock-reflect.jar",
)

fb_native.remote_file(
name = "download-powermock-module-junit4-rule.jar",
sha1 = "4847638c5729b9f203e21144b0bdb5d34d888473",
url = "mvn:org.powermock:powermock-module-junit4-rule:jar:1.6.2",
name = "powermock-reflect.jar",
sha1 = "9a8b85397c5a72923962ee9e6bf774e8458803bb",
url = "mvn:org.powermock:powermock-reflect:jar:2.0.7",
)

rn_prebuilt_jar(
name = "powermock-classloading-xstream",
binary_jar = ":download-powermock-classloading-xstream.jar",
visibility = ["//ReactAndroid/..."],
name = "powermock-api-mockito2",
binary_jar = ":powermock-api-mockito2.jar",
)

fb_native.remote_file(
name = "download-powermock-classloading-xstream.jar",
sha1 = "3ced31cd7024fe365b9f3c8082d22c02434577da",
url = "mvn:org.powermock:powermock-classloading-xstream:jar:1.6.2",
name = "powermock-api-mockito2.jar",
sha1 = "9f40156d9f6f65c6459a65e34f3c7c4fef8b3c49",
url = "mvn:org.powermock:powermock-api-mockito2:jar:2.0.7",
)

rn_prebuilt_jar(
name = "powermock-api-support",
binary_jar = ":powermock-api-support.jar",
)

fb_native.remote_file(
name = "powermock-api-support.jar",
sha1 = "e311918de98f5d8b726031ca840664691599fd71",
url = "mvn:org.powermock:powermock-api-support:jar:2.0.7",
)

rn_prebuilt_jar(
name = "powermock-classloading-base",
binary_jar = ":download-powermock-classloading-base.jar",
visibility = ["//ReactAndroid/..."],
binary_jar = ":powermock-classloading-base.jar",
)

fb_native.remote_file(
name = "download-powermock-classloading-base.jar",
sha1 = "c8bfc10731a02d3b241892cf2c334a754d473ca7",
url = "mvn:org.powermock:powermock-classloading-base:jar:1.6.2",
name = "powermock-classloading-base.jar",
sha1 = "58ae5d3087ddfee5a591131d337907401276f7d4",
url = "mvn:org.powermock:powermock-classloading-base:jar:2.0.7",
)

rn_prebuilt_jar(
name = "xstream",
binary_jar = ":download-xstream.jar",
visibility = ["//ReactAndroid/..."],
name = "powermock-classloading-xstream-prebuilt",
binary_jar = ":powermock-classloading-xstream.jar",
)

fb_native.remote_file(
name = "download-xstream.jar",
sha1 = "97e5013f391487cce4de6b0eebcde21549e91872",
url = "mvn:com.thoughtworks.xstream:xstream:jar:1.4.2",
name = "powermock-classloading-xstream.jar",
sha1 = "2ec4d94a584f12b0aa1165279e92ef3d5fda1b93",
url = "mvn:org.powermock:powermock-classloading-xstream:jar:2.0.7",
)

rn_prebuilt_jar(
name = "powermock-reflect",
binary_jar = ":download-powermock-reflect.jar",
visibility = ["//ReactAndroid/..."],
name = "powermock-core",
binary_jar = ":powermock-core.jar",
)

fb_native.remote_file(
name = "download-powermock-reflect.jar",
sha1 = "1af1bbd1207c3ecdcf64973e6f9d57dcd17cc145",
url = "mvn:org.powermock:powermock-reflect:jar:1.6.2",
name = "powermock-core.jar",
sha1 = "484c06b406c5a21a4a2ad39f6fe36a0f77834aa9",
url = "mvn:org.powermock:powermock-core:jar:2.0.7",
)

rn_prebuilt_jar(
name = "javassist",
binary_jar = ":download-javassist.jar",
visibility = ["//ReactAndroid/..."],
name = "powermock-module-junit-common-prebuilt",
binary_jar = ":powermock-module-junit-common.jar",
)

fb_native.remote_file(
name = "download-javassist.jar",
sha1 = "a9cbcdfb7e9f86fbc74d3afae65f2248bfbf82a0",
url = "mvn:org.javassist:javassist:jar:3.20.0-GA",
name = "powermock-module-junit-common.jar",
sha1 = "e890f92292aa525000a8fa95a8ca4015e3eb78b8",
url = "mvn:org.powermock:powermock-module-junit4-common:jar:2.0.7",
)

rn_prebuilt_jar(
name = "mockito-all",
binary_jar = ":download-mockito-all.jar",
visibility = ["//ReactAndroid/..."],
name = "powermock-module-junit-rule-prebuilt",
binary_jar = ":powermock-module-junit-rule.jar",
)

fb_native.remote_file(
name = "download-mockito-all.jar",
sha1 = "539df70269cc254a58cccc5d8e43286b4a73bf30",
url = "mvn:org.mockito:mockito-all:jar:1.10.19",
name = "powermock-module-junit-rule.jar",
sha1 = "d0d14709ffec2c3cbad0e3d6256bc8ace682398d",
url = "mvn:org.powermock:powermock-module-junit4-rule:jar:2.0.7",
)

rn_prebuilt_jar(
name = "xmlpull",
binary_jar = ":download-xmlpull.jar",
visibility = ["//ReactAndroid/..."],
name = "javassist-prebuilt",
binary_jar = ":javassist.jar",
)

fb_native.remote_file(
name = "download-xmlpull.jar",
sha1 = "2b8e230d2ab644e4ecaa94db7cdedbc40c805dfa",
url = "mvn:xmlpull:xmlpull:jar:1.1.3.1",
name = "javassist.jar",
sha1 = "f63e6aa899e15eca8fdaa402a79af4c417252213",
url = "mvn:org.javassist:javassist:jar:3.27.0-GA",
)

rn_prebuilt_jar(
name = "xpp3",
binary_jar = ":download-xpp3.jar",
visibility = ["//ReactAndroid/..."],
name = "xstream-prebuilt",
binary_jar = ":xstream.jar",
)

fb_native.remote_file(
name = "download-xpp3.jar",
sha1 = "19d4e90b43059058f6e056f794f0ea4030d60b86",
url = "mvn:xpp3:xpp3_min:jar:1.1.4c",
name = "xstream.jar",
sha1 = "6c120c45a8c480bb2fea5b56502e3993ddd74fd2",
url = "mvn:com.thoughtworks.xstream:xstream:jar:1.4.11.1",
)
20 changes: 20 additions & 0 deletions ReactAndroid/src/main/third-party/android/androidx/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,15 @@ fb_native.android_library(
],
)

fb_native.android_library(
name = "test-monitor",
visibility = ["PUBLIC"],
exported_deps = [
":annotation",
":test-monitor-binary",
],
)

fb_native.android_library(
name = "vectordrawable",
visibility = ["PUBLIC"],
Expand Down Expand Up @@ -448,6 +457,11 @@ fb_native.android_prebuilt_aar(
aar = ":swiperefreshlayout-binary-aar",
)

fb_native.android_prebuilt_aar(
name = "test-monitor-binary",
aar = ":test-monitor-binary-aar",
)

fb_native.android_prebuilt_aar(
name = "vectordrawable-binary",
aar = ":vectordrawable-binary-aar",
Expand Down Expand Up @@ -625,6 +639,12 @@ fb_native.remote_file(
url = "mvn:androidx.swiperefreshlayout:swiperefreshlayout:aar:1.0.0",
)

fb_native.remote_file(
name = "test-monitor-binary-aar",
sha1 = "d2f75d117c055f35c8ebbd4f96fabc2137df9e4d",
url = "mvn:androidx.test:monitor:aar:1.2.0",
)

fb_native.remote_file(
name = "vectordrawable-binary-aar",
sha1 = "33d1eb71849dffbad12add134a25eb63cad4a1eb",
Expand Down
20 changes: 10 additions & 10 deletions ReactAndroid/src/main/third-party/java/asm/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ rn_prebuilt_jar(

fb_native.remote_file(
name = "download-asm.jar",
sha1 = "2fd56467a018aafe6ec6a73ccba520be4a7e1565",
url = "mvn:org.ow2.asm:asm:jar:5.0.1",
sha1 = "d74d4ba0dee443f68fb2dcb7fcdb945a2cd89912",
url = "mvn:org.ow2.asm:asm:jar:7.0",
)

rn_prebuilt_jar(
Expand All @@ -33,8 +33,8 @@ rn_prebuilt_jar(

fb_native.remote_file(
name = "download-asm-commons.jar",
sha1 = "7b7147a390a93a14d2edfdcf3f7b0e87a0939c3e",
url = "mvn:org.ow2.asm:asm-commons:jar:5.0.1",
sha1 = "478006d07b7c561ae3a92ddc1829bca81ae0cdd1",
url = "mvn:org.ow2.asm:asm-commons:jar:7.0",
)

rn_prebuilt_jar(
Expand All @@ -45,8 +45,8 @@ rn_prebuilt_jar(

fb_native.remote_file(
name = "download-asm-tree.jar",
sha1 = "1b1e6e9d869acd704056d0a4223071a511c619e6",
url = "mvn:org.ow2.asm:asm-tree:jar:5.0.1",
sha1 = "29bc62dcb85573af6e62e5b2d735ef65966c4180",
url = "mvn:org.ow2.asm:asm-tree:jar:7.0",
)

rn_prebuilt_jar(
Expand All @@ -57,8 +57,8 @@ rn_prebuilt_jar(

fb_native.remote_file(
name = "download-asm-util.jar",
sha1 = "7c8caddfbd0b2d7b844f8fcc75175b9cb9cf4724",
url = "mvn:org.ow2.asm:asm-util:jar:5.0.1",
sha1 = "18d4d07010c24405129a6dbb0e92057f8779fb9d",
url = "mvn:org.ow2.asm:asm-util:jar:7.0",
)

rn_prebuilt_jar(
Expand All @@ -69,6 +69,6 @@ rn_prebuilt_jar(

fb_native.remote_file(
name = "download-asm-analysis.jar",
sha1 = "e286fbee48efacb4e7c175f7948d9d8b2ab52352",
url = "mvn:org.ow2.asm:asm-analysis:jar:5.0.1",
sha1 = "4b310d20d6f1c6b7197a75f1b5d69f169bc8ac1f",
url = "mvn:org.ow2.asm:asm-analysis:jar:7.0",
)
Loading

0 comments on commit 6a78b32

Please sign in to comment.