Android Instrumentations tests are ready to be run in github/CI open source environment

Reviewed By: mkonicek

Differential Revision: D2769217

fb-gh-sync-id: 7469af816241d8b642753cca21f6542b971e9572
This commit is contained in:
Konstantin Raev
2015-12-21 09:37:27 -08:00
committed by facebook-github-bot-9
parent 040909904c
commit a99c5160ee
26 changed files with 2306 additions and 1 deletions

View File

@@ -0,0 +1,57 @@
/**
* Copyright (c) 2014-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 com.facebook.react.testing;
import javax.annotation.Nullable;
import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
/**
* NativeModule for tests that allows assertions from JS to propagate to Java.
*/
public class AssertModule extends BaseJavaModule {
private boolean mGotSuccess;
private boolean mGotFailure;
private @Nullable String mFirstFailureStackTrace;
@Override
public String getName() {
return "Assert";
}
@ReactMethod
public void fail(String stackTrace) {
if (!mGotFailure) {
mGotFailure = true;
mFirstFailureStackTrace = stackTrace;
}
}
@ReactMethod
public void success() {
mGotSuccess = true;
}
/**
* Allows the user of this module to verify that asserts are actually being called from JS and
* that none of them failed.
*/
public void verifyAssertsAndReset() {
assertFalse("First failure: " + mFirstFailureStackTrace, mGotFailure);
assertTrue("Received no assertions during the test!", mGotSuccess);
mGotFailure = false;
mGotSuccess = false;
mFirstFailureStackTrace = null;
}
}