mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +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:
parent
e788e8fa0f
commit
0e19f88a04
34
.gitignore
vendored
34
.gitignore
vendored
@ -2,28 +2,28 @@
|
|||||||
default.properties
|
default.properties
|
||||||
gen
|
gen
|
||||||
assets/www/cordova.js
|
assets/www/cordova.js
|
||||||
framework/assets/www/.tmp*
|
|
||||||
local.properties
|
local.properties
|
||||||
framework/lib
|
|
||||||
proguard.cfg
|
proguard.cfg
|
||||||
proguard.cfg
|
proguard.cfg
|
||||||
proguard-project.txt
|
proguard-project.txt
|
||||||
framework/bin
|
/framework/lib
|
||||||
framework/test/org/apache/cordova/*.class
|
/framework/build
|
||||||
framework/assets/www/.DS_Store
|
/framework/bin
|
||||||
framework/assets/www/cordova-*.js
|
/framework/assets/www/.DS_Store
|
||||||
framework/assets/www/phonegap-*.js
|
/framework/assets/www/cordova-*.js
|
||||||
framework/libs
|
/framework/assets/www/phonegap-*.js
|
||||||
framework/javadoc-public
|
/framework/libs
|
||||||
framework/javadoc-private
|
/framework/javadoc-public
|
||||||
test/libs
|
/framework/javadoc-private
|
||||||
|
/test/libs
|
||||||
example
|
example
|
||||||
./test
|
/test/bin
|
||||||
test/bin
|
/test/assets/www/.tmp*
|
||||||
test/assets/www/.tmp*
|
/test/assets/www/cordova.js
|
||||||
test/assets/www/cordova.js
|
/test/gradle
|
||||||
test/cordova/plugins/org.apache.cordova.device/www/device.js
|
/test/gradlew
|
||||||
test/cordova/plugins/org.apache.cordova.device/src/android/Device.java
|
/test/build
|
||||||
|
.gradle
|
||||||
tmp/**
|
tmp/**
|
||||||
.metadata
|
.metadata
|
||||||
tmp/**/*
|
tmp/**/*
|
||||||
|
@ -18,34 +18,47 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
-->
|
-->
|
||||||
# Android Native Tests #
|
# Android Native Tests
|
||||||
|
|
||||||
These tests are designed to verify Android native features and other Android specific features.
|
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.
|
### Setting env vars
|
||||||
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
|
Run:
|
||||||
has to be installed for the onScrollChanged tests to work correctly. It can be
|
|
||||||
|
../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
|
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`
|
To run manual tests:
|
||||||
0. Run tests by clicking on "CordovaNativeTests" app icon on the device
|
|
||||||
|
|
||||||
To run from Eclipse:
|
./gradlew installDebug
|
||||||
|
|
||||||
0. Import Android project into Eclipse
|
To run unit tests:
|
||||||
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
|
|
||||||
|
|
||||||
## Automatic Runs ##
|
./gradlew connectedAndroidTest
|
||||||
|
|
||||||
Once you have installed the test, you can launch and run the tests
|
## Android Studio
|
||||||
automatically with the below command:
|
|
||||||
|
|
||||||
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_
|
||||||
|
75
test/build.gradle
Normal file
75
test/build.gradle
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
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
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// GENERATED FILE! DO NOT EDIT!
|
||||||
|
|
||||||
|
apply plugin: 'android'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:1.0.0+'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
apply from: '../framework/cordova.gradle'
|
||||||
|
cdvCompileSdkVersion = privateHelpers.getProjectTarget()
|
||||||
|
cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
manifest.srcFile 'AndroidManifest.xml'
|
||||||
|
java.srcDirs = ['src']
|
||||||
|
resources.srcDirs = ['src']
|
||||||
|
res.srcDirs = ['res']
|
||||||
|
assets.srcDirs = ['assets']
|
||||||
|
}
|
||||||
|
androidTest {
|
||||||
|
java.srcDirs = ['androidTest/src']
|
||||||
|
resources.srcDirs = ['androidTest/src']
|
||||||
|
res.srcDirs = []
|
||||||
|
assets.srcDirs = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
testInstrumentationRunner "android.test.InstrumentationTestRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileSdkVersion cdvCompileSdkVersion
|
||||||
|
buildToolsVersion cdvBuildToolsVersion
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_6
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_6
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
debugCompile project(path: ":CordovaLib", configuration: "debug")
|
||||||
|
releaseCompile project(path: ":CordovaLib", configuration: "release")
|
||||||
|
androidTestCompile fileTree(dir: 'androidTest/libs', include: '*.jar')
|
||||||
|
}
|
||||||
|
|
@ -8,5 +8,5 @@
|
|||||||
# project structure.
|
# project structure.
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-19
|
target=android-21
|
||||||
android.library.reference.1=../framework
|
android.library.reference.1=../framework
|
||||||
|
4
test/settings.gradle
Normal file
4
test/settings.gradle
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
include ":"
|
||||||
|
include ":CordovaLib"
|
||||||
|
project(':CordovaLib').projectDir = new File('../framework')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user