mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-30 00:00:04 +08:00
Make unit tests work with Gradle
Had to split the test app from the tests, since that's how gradle forces you to do it.
This commit is contained in:
+34
-21
@@ -7,9 +7,9 @@
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@@ -18,34 +18,47 @@
|
||||
# under the License.
|
||||
#
|
||||
-->
|
||||
# Android Native Tests #
|
||||
# Android Native Tests
|
||||
|
||||
These tests are designed to verify Android native features and other Android specific features.
|
||||
They currently are in disrepair, and don't pass / work on KitKat+ :(.
|
||||
|
||||
## Initial Setup ##
|
||||
## Initial Setup
|
||||
|
||||
There really isn't any manual setup to do. The ant script takes care of that.
|
||||
You don't even need to compile cordova-x.y.z.jar or copy it, because
|
||||
project.properties has a library reference to ../framework. However, Robotium
|
||||
has to be installed for the onScrollChanged tests to work correctly. It can be
|
||||
### Setting env vars
|
||||
|
||||
Run:
|
||||
|
||||
../bin/check_reqs
|
||||
|
||||
Use the output to set your `ANDROID_HOME` and `JAVA_HOME` environment variables.
|
||||
|
||||
### Adding `gradlew`
|
||||
|
||||
Copy it from a freshly created project:
|
||||
|
||||
../bin/create foo
|
||||
(cd foo && cordova/build --gradle; cp -r gradlew gradle ..)
|
||||
rm -r foo
|
||||
|
||||
### Robotium
|
||||
|
||||
Robotium has to be installed for the onScrollChanged tests to work correctly. It can be
|
||||
found at https://code.google.com/p/robotium/ and the jar should be put in the
|
||||
'libs' directory'.
|
||||
'androidTests/libs' directory'.
|
||||
|
||||
To run manually from command line:
|
||||
## Running
|
||||
|
||||
0. Build by entering `ant debug install`
|
||||
0. Run tests by clicking on "CordovaNativeTests" app icon on the device
|
||||
To run manual tests:
|
||||
|
||||
To run from Eclipse:
|
||||
./gradlew installDebug
|
||||
|
||||
0. Import Android project into Eclipse
|
||||
0. Ensure Project properties "Java Build Path" includes the lib/cordova-x.y.z.jar
|
||||
0. Create run configuration if not already created
|
||||
0. Run As -> Android JUnit Test
|
||||
To run unit tests:
|
||||
|
||||
## Automatic Runs ##
|
||||
./gradlew connectedAndroidTest
|
||||
|
||||
Once you have installed the test, you can launch and run the tests
|
||||
automatically with the below command:
|
||||
## Android Studio
|
||||
|
||||
adb shell am instrument -w org.apache.cordova.test/android.test.InstrumentationTestRunner
|
||||
1. Use "Non-Android Studio Project" to import the `test` directory.
|
||||
2. Right click on the `junit` package in the left-side nav
|
||||
3. Select "Debug"`->`_The one with the Android icon_
|
||||
|
||||
Reference in New Issue
Block a user