diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index b9dc2f046..ef343d4a7 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -256,6 +256,14 @@ dependencies { compile 'com.squareup.okhttp:okhttp-ws:2.5.0' compile 'com.squareup.okio:okio:1.6.0' compile 'org.webkit:android-jsc:r174650' + + testCompile "junit:junit:${JUNIT_VERSION}" + testCompile "org.powermock:powermock-api-mockito:${POWERMOCK_VERSION}" + testCompile "org.powermock:powermock-module-junit4-rule:${POWERMOCK_VERSION}" + testCompile "org.powermock:powermock-classloading-xstream:${POWERMOCK_VERSION}" + testCompile "org.mockito:mockito-core:${MOCKITO_CORE_VERSION}" + testCompile "org.easytesting:fest-assert-core:${FEST_ASSERT_CORE_VERSION}" + testCompile("org.robolectric:robolectric:${ROBOLECTRIC_VERSION}") } apply from: 'release.gradle' diff --git a/ReactAndroid/gradle.properties b/ReactAndroid/gradle.properties index 96433c14b..e038115dd 100644 --- a/ReactAndroid/gradle.properties +++ b/ReactAndroid/gradle.properties @@ -6,3 +6,9 @@ POM_ARTIFACT_ID=react-native POM_PACKAGING=aar android.useDeprecatedNdk=true + +MOCKITO_CORE_VERSION=1.+ +POWERMOCK_VERSION=1.6.2 +ROBOLECTRIC_VERSION=3.0 +JUNIT_VERSION=4.12 +FEST_ASSERT_CORE_VERSION=2.0M10 diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/storage/AsyncStorageModuleTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/storage/AsyncStorageModuleTest.java index bd7076fc9..c11e9ba93 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/storage/AsyncStorageModuleTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/storage/AsyncStorageModuleTest.java @@ -53,7 +53,7 @@ import static org.fest.assertions.api.Assertions.assertThat; * Tests for {@link AsyncStorageModule}. */ @PrepareForTest({Arguments.class}) -@PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "android.*"}) +@PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "android.*", "org.json.*"}) @RunWith(RobolectricTestRunner.class) public class AsyncStorageModuleTest { diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/timing/TimingModuleTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/timing/TimingModuleTest.java index 0d14cdc43..219bccf13 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/timing/TimingModuleTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/timing/TimingModuleTest.java @@ -77,9 +77,9 @@ public class TimingModuleTest { PowerMockito.mockStatic(ReactChoreographer.class); when(ReactChoreographer.getInstance()).thenReturn(mChoreographerMock); - CatalystInstance catalystInstance = mock(CatalystInstance.class); + CatalystInstance reactInstance = mock(CatalystInstance.class); ReactApplicationContext reactContext = mock(ReactApplicationContext.class); - when(reactContext.getCatalystInstance()).thenReturn(catalystInstance); + when(reactContext.getCatalystInstance()).thenReturn(reactInstance); mCurrentTimeNs = 0; mPostFrameCallbackHandler = new PostFrameCallbackHandler(); @@ -92,7 +92,7 @@ public class TimingModuleTest { mTiming = new Timing(reactContext); mJSTimersMock = mock(JSTimersExecution.class); - when(catalystInstance.getJSModule(JSTimersExecution.class)).thenReturn(mJSTimersMock); + when(reactInstance.getJSModule(JSTimersExecution.class)).thenReturn(mJSTimersMock); mTiming.initialize(); } diff --git a/ReactAndroid/src/test/java/org/mockito/configuration/MockitoConfiguration.java b/ReactAndroid/src/test/java/org/mockito/configuration/MockitoConfiguration.java new file mode 100644 index 000000000..20f4aa035 --- /dev/null +++ b/ReactAndroid/src/test/java/org/mockito/configuration/MockitoConfiguration.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +package org.mockito.configuration; + +/** + * Disables the Mockito cache to prevent Mockito & Robolectric bugs. + * + * Mockito loads this with reflection, so this class might appear unused. + */ +@SuppressWarnings("unused") +public class MockitoConfiguration extends DefaultMockitoConfiguration { + + /* (non-Javadoc) + * @see org.mockito.configuration.IMockitoConfiguration#enableClassCache() + */ + public boolean enableClassCache() { + return false; + } +}