I'm having trouble understanding how the integration testing runs with android. I went through the documentation and got their sample project set up and I can successfully run tests. However, I am utterly confused on how to put the pieces together to create my own tests for my own project. I've already completed making integration tests for iOS, and I wish to reuse the javascript files I wrote for testing, however in the sample app it looks like they made new test files...? Anyways I'll explain my probably flawed understanding and would appreciate it if anyone could help me put the pieces together.
My understanding is as follows:
1. A script for integration tests is invoked and it starts off by checking if buck is installed:
set -e
which buck > /dev/null || {
echo "React Native uses the Buck build tool to run tests. Please install Buck: https://buckbuild.com/setup/install.html";
exit 1;
}
2. The script calls some method in build gradle which compiles native code. (Not sure if my gradle script should have the same implementation or slightly different than this)
echo "Compiling native code..."
./gradlew :ReactAndroid:packageReactNdkLibsForBuck
3. The script then builds some testbundle which includes all of the tests that the user would like to run. I'm not sure where these tests are located either. Then some output is placed.
echo "Building JS bundle..."
node local-cli/cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
4. then using some buck file, dependencies are loaded and ready to go, and finally installed onto the device. Not sure if I need the dependencies or if this file should be completely copied.
echo "Installing test app on the device..."
buck fetch ReactAndroid/src/androidTest/buck-runner:instrumentation-tests
buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests
echo "Running integration tests..."
adb shell am instrument -w com.facebook.react.tests/android.support.test.runner.AndroidJUnitRunner
- The last starts the tests that have been loaded in and compiled.
So as you can guess from my not-so-shrewd explanation, I'm very confused about what files to copy to get something working minimally as my own tests. Any advice, or guidance in this area would be much appreciated. reference to documentation that I may have overlooked is also okay. Mostly I would appreciate some sort of flow of how these tests run so I can implement a very simple one to expand upon myself. (so what files I should copy, what files I should change, etc).