googlesamples / android-testing-templates Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
Which means that the apk is built when unit tests are run and for complex apps it takes a long time.
./gradlew app:test
from command line works properly
Adding such dependency in the app module causes an "Failed to resolve" error.
repositories {
maven { url "https://jitpack.io" }
mavenCentral()
}
dependencies {
// App's dependencies, including test
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.github.PhilJay:MPAndroidChart:v2.0.9'
...
If the same repositories are declared in the module-flavor1-androidTest-only module the dependencies resolve correctly.
I am having this issue. Need Urgent Help
C:\Users\SmitShah\Downloads\jwplayer-sdk-android-demo-master\jwplayer-sdk-android-demo-master\CastCompanionLibrary-android\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.1\res\drawable\abc_textfield_search_material.xml
Error:(18, 87) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_textfield_search_activated_mtrl_alpha').
Error:(19, 89) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_textfield_search_activated_mtrl_alpha').
C:\Users\SmitShah\Downloads\jwplayer-sdk-android-demo-master\jwplayer-sdk-android-demo-master\CastCompanionLibrary-android\build\intermediates\exploded-aar\com.google.android.gms\play-services-base\8.3.0\res\drawable\common_google_signin_btn_icon_dark.xml
Error:(5, 27) No resource found that matches the given name (at 'drawable' with value '@drawable/common_google_signin_btn_icon_dark_disabled').
Error:(8, 27) No resource found that matches the given name (at 'drawable' with value '@drawable/common_google_signin_btn_icon_dark_pressed').
Error:(11, 27) No resource found that matches the given name (at 'drawable' with value
In Android Studio
- In the Build Variants window, make sure the Android Instrumentation Tests option is selected.
- Open a Instrumentation test class like EspressoTest.java or UiAutomatorTest.java
- Right click on the class and Run as Android Test.
For me (Android Studio 2.3.3 and 3 beta 6) there is no selection for this in "Build Variants".
On right clicking I also don't get "Run as ..." as an option, only "Run '...'".
What is the current equivalent for these instructions?
Process finished with exit code 1
Class not found: "com.example.android.testing.blueprint.ui.espresso.EspressoTestForFlavor2"Empty test suite.
Just spotted something
the issue link has the old project name url which is incorrect,it should be:
https://github.com/googlesamples/android-testing-templates/issues
does it plan to include the sample of robolectric
for the unit test framework?
My project has a similar setup like the testing blueprint with an extra module for our Android tests. The app module has multiple flavors and build types (although I think that doesn't matter). If I try to create a code coverage report, then the coverage is 0% everywhere.
The Gradle plugin is trying to find and run the Android tests in the app module, but there are no tests. They are in the separate module.
Let me know if you need more information.
(Repost from the bug tracker https://code.google.com/p/android/issues/detail?id=199555)
I'm mentioning this because adding Play Services dependency to the app module causes an error.
dependencies {
// App's dependencies, including test
compile('com.google.android.gms:play-services-base:7.5.0')
...
Reported error:
:module-flavor1-androidTest-only:processDebugManifest
/somewhere/android-testing-templates/AndroidTestingBlueprint/module-flavor1-androidTest-only/build/intermediates/manifests/full/debug/AndroidManifest.xml:29:28-65 : No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').
If there is a better place to report this issue please direct me to it.
I create a separate test module like module-flavor1-androidTest-only
, and I get a error blew
Error:(36, 28) No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').
how can I fix this
My steps:
File -> New -> Project from version control -> github
Git URL:
https://github.com/googlesamples/android-testing-templates.git
then I see this:
I clicked "Configure"
and see this:
I clicked "ok
and it does not work:
"
Hi,
Thank you for your work but I'm having an error trying to run tests inside a separate module.
Running tests inside module-flavor1-androidTest-only
module only produces Empty test suite error by both Android Studio and gradle command ./gradlew module-flavor1-androidTest-only:connectedAndroidTest
Another note, if I run a normal instrument test (which is located inside app
module) first then the above tests can run without problem. My suspect is that the gradle command above doesn't install the app apk before execute the tests.
Can you guys check it out.
Thanks.
If you try to minify (proguard) debug build by un-commenting :
debug {
// Run code coverage reports by default on debug builds.
testCoverageEnabled = true
// Uncomment this to run test against a minified version of the production APK
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testProguardFile 'proguard-test-rules.pro'
}
in app's build.gradle, *-androidTest.apk doesnt get obfuscated and method count is not reduced.
I had an issue when trying to set up a testing module, based on the model provided in module-flavor1-androidTest-only
. I eventually realized that it was due to the fact that I had ABI splits set up in my application, leading the connectedAndroidTest
task to fail.
I was able to reproduce the issue in this project by adding the following snippet inside the android
block of the app module's build.gradle
file:
splits.abi {
enable true
reset()
include 'armeabi', 'armeabi-v7a'
}
By running ./gradlew module-flavor1-androidTest-only:connectedDebugAndroidTest
, I get the same exception as in my application.
> Expected configuration ':module-flavor1-androidTest-only:testTarget-metadata' to contain exactly one file, however, it contains no files.
By debugging Gradle, I found that the error occurs because TestApplicationData#getTestedApks
handles modules with splits differently, since testedApkFiles.size() > 1 && splitSelectExe != null
evaluates to true
. The code then fails at TestApplicationData#loadMetadata
.
I ended up disabling splits in my app, only when I'm running the instrumentation tests in this module. Any idea for a better workaround in the Gradle setup? Or is this just a bug in the Android Gradle Plugin which should be reported to their development team?
On the first build, doesn't find this package:
Error:(24, 66) error: package com.example.android.testing.blueprint.androidlibrarymodule does not exist
I tried to add an Espresso test to module-flavor1-androidTest-only
, but I haven't gotten very far.
I copied EspressoTest
into module-flavor1-androidTest-only
and added the dependencies that it seemed to need.
My changes: master...bsstokes:add-espresso-test-to-test-only-module
When I run this new test, I'm getting:
java.lang.NullPointerException: Attempt to invoke interface method 'void android.support.v7.widget.DecorContentParent.setWindowCallback(android.view.Window$Callback)' on a null object reference
at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:410)
at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:323)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.android.testing.blueprint.HelloTestingBlueprintActivity.onCreate(HelloTestingBlueprintActivity.kt:44)
at android.app.Activity.performCreate(Activity.java:6999)
at android.app.Activity.performCreate(Activity.java:6990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.support.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:532)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.testing.blueprint.flavor1/com.example.android.testing.blueprint.HelloTestingBlueprintActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void android.support.v7.widget.DecorContentParent.setWindowCallback(android.view.Window$Callback)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void android.support.v7.widget.DecorContentParent.setWindowCallback(android.view.Window$Callback)' on a null object reference
at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:410)
at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:323)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.android.testing.blueprint.HelloTestingBlueprintActivity.onCreate(HelloTestingBlueprintActivity.kt:44)
at android.app.Activity.performCreate(Activity.java:6999)
at android.app.Activity.performCreate(Activity.java:6990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.support.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:532)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
... 9 more
Test running failed: Instrumentation run failed due to 'Process crashed.'
Does anybody have any ideas?
It'd be awesome if somebody could add an Espresso test to module-flavor1-androidTest-only
as an example.
By default, the test module (com.android.test
) targets the debug
build type.
The official documentation mentions that it is possible to change this default configuration and target a different build type (eg release
with minification enabled).
Could you add an example of such configuration in the samples?
Thx
No resource found that matches the given name (at 'drawable' with value '@drawable/abc_textfield_search_activated_mtrl_alpha').
android-testing-templates-master\AndroidTestingBlueprint\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.0.1\res\drawable\abc_textfield_search_material.xml
Error:Execution failed for task ':app:processFlavor1DebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'Android\sdk\build-tools\23.0.1\aapt.exe'' finished with non-zero exit value 1
Hello,
I want to use the com.android.test
plugin with JUnit3 instrumentation tests. Unfortunately this does not work because the ActivityInstrumentationTestCase2
class cannot be found by dalvik when the tests are started. Am I doing something wrong?
I forked the android-testing-templates here and pushed the changes for JUnit3.
Logcat reports:
Unable to resolve superclass of Lcom/example/android/testing/blueprint/test/AndroidTestOnlyModuleTest;
This results in following output when running am instrument
:
Time: 0
There was 1 failure:
1) com.example.android.testing.blueprint.test.AndroidTestOnlyModuleTest
java.lang.ClassNotFoundException: com.example.android.testing.blueprint.test.AndroidTestOnlyModuleTest
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:204)
at android.support.test.internal.runner.TestLoader.doLoadClass(TestLoader.java:94)
at android.support.test.internal.runner.TestLoader.loadIfTest(TestLoader.java:115)
at android.support.test.internal.runner.TestRequestBuilder.loadClassesFromClassPath( TestRequestBuilder.java:712)
at android.support.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:661)
at android.support.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:329)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:226)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
Caused by: java.lang.NoClassDefFoundError: com/example/android/testing/blueprint/test/ AndroidTestOnlyModuleTest
... 9 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.android.testing.blueprint.test.AndroidTestOnlyModuleTest" on path: DexPathList[[zip file "/data/app/com.example.android.testing.blueprint.test-2.apk", zip file "/data/app/com.example.android.testing.blueprint.flavor1-2.apk"], nativeLibraryDirectories=[/data/app-lib/com.example.android.testing.blueprint.test-2, /data/app-lib/com.example.android.testing.blueprint.flavor1-2, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
... 9 more
FAILURES!!!
Tests run: 0, Failures: 1
Issue:
After adding Play Services to app module, gradle sync fails with message:
(...)/AndroidTestingBlueprint/module-flavor1-androidTest-only/build/intermediates/manifests/full/debug/AndroidManifest.xml
Error:(40, 28) No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').
Use case:
main app module uses Google Play Services dependency:
After adding dependency, grade sync fails.
You can find separated changes committed here: jskierbi@6bbd1ac
Is it possible to fix this?
Note: Generating JaCoCo reports from command-line via Gradle for the app module is currently not working: [https://code.google.com/p/android/issues/detail?id=144664]
Please use my articles for fixing that:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.