Jenkins failing robolectric test cases...! - android

I am trying to build my android project on Jenkins 2.0 server on Ubuntu machine.
I am running the following commands for that purpose:-
./gradlew clean (this is working fine)
./gradlew build (this is failing random number of test cases)
However I also install Jenkins 2.0 on my Windows 7 machine and run the same commands as above, and it was passing all test cases every time. I am not understanding what is wrong with that.
I did lot of debugging but could not find any solution, please help me to get rid out of this thing...!
This is my 34th build log on Jenkins
testPreCondition FAILED
java.lang.NullPointerException at ConfigurationFragmentTest.java:36
handleBackButtonPressing FAILED
java.lang.NullPointerException at ConfigurationFragmentTest.java:36
48 tests completed, 2 failed
:app:testDebugUnitTest FAILED
This is my 35th build log on Jenkins without making any code changes
> handleBackButtonPressing FAILED
java.lang.NullPointerException at ConfigurationFragmentTest.java:36
> testPreCondition FAILED
java.lang.NullPointerException at ConfigurationFragmentTest.java:36
> testPreconditions FAILED
java.lang.NullPointerException at UpdateTabFragmentTest.java:30
> testPreconditions FAILED
java.lang.NullPointerException at ServiceTabFragmentTest.java:29
> testPreConditionIsNotNull FAILED
java.lang.NullPointerException at HomeActivityTest.java:63
48 tests completed, 5 failed
:app:testDebugUnitTest FAILED

You should check the Jenkins console output for something like
"WARNING: No manifest file found " in the console output.
Those NPEs are typical for missing resources.
The most common source for failing robolectric builds on different environmnets is probably robolectric not beeing able to load any resources.
Since robolectric needs to know where your Android Manifest is, you may have to provide a extra robolectric.properties for the build
http://robolectric.org/configuring/

Related

Android Github action with Gradle Managed Device

I try to make a CI test with Gradle Managed Device and Github action. I made several attempts, but I mostly run into
Execution failed for task ':app:nexusOneApi30Setup'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.ManagedDeviceSetupTask$ManagedDeviceSetupRunnable
> java.lang.IllegalStateException: Gradle was not able to complete device setup for: dev30_aosp_atd_x86_Nexus_One
This could be due to having insufficient resources to provision the number of
devices requested. Try running the test again and request fewer devices or
fewer shards.
As source I use https://github.com/android/testing-samples/tree/main/ui/espresso/ScreenshotSample in my fork which works local properly

Gradle error trying to run nativescript app on android emulator on mac

I'm trying to run a nativescript app on android using tns run android
I'm always getting gradle error:
FAILURE: Build failed with an exception.
* Where:
Build file:
'/Volumes/My_SSD/myproject/platforms/tempPlugin/kinvey_nativescript_sdk/bui
ld.gradle' line: 28
* What went wrong:
A problem occurred evaluating root project '`kinvey_nativescript_sdk`'.
> Failed to apply plugin [class 'org.gradle.api.plugins.BasePlugin']
> Could not create service of type OutputFilesRepository using ExecutionServices.createOutputFilesRepository().`
I tried the following:
Run ./gradlew --stacktrace but I got this error:
Caused by: org.gradle.cache.LockTimeoutException: Timeout waiting to lock
execution history cache
(/Volumes/My_SSD/myproject/platforms/tempPlugin/kinvey_nativescript_sdk/.gr
adle/5.1.1/executionHistory). It is currently in use by another Gradle
instance.
Owner PID: unknown
Our PID: 50331
Owner Operation: unknown
Our operation:
Lock file:
/Volumes/My_SSD/myproject/platforms/tempPlugin/kinvey_nativescript_sdk/.gra
dle/5.1.1/executionHistory/executionHistory.lock
Deleted .lock files manually and re-ran tns run android but I got the same error again
Run
chmod R+x/Volumes/My_SSD/myproject/platforms/tempPlugin/kinvey_nativescript_sdk
Didn't fix the problem
The app runs fine on ios emulator and but not on android
I was having the same problem, looks to be related with this Gradle issue.
The workaround I found here is to move the project to the home folder (~).

Android Espresso shards randomly fail with INSTALL_FAILED_INVALID_APK

EDIT: Below is the original post. It was the initial issue I had ran into, but repeating my steps over and over I am getting different results. The first time I tried to run my shards after posting this, I got:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ProgressiveApp:packageInternalStaging'.
> invalid distance too far back
The next time:
> invalid code lengths set
And the next:
> Unexpected end of ZLIB input stream
All three appear to be zip/compression related issues. Perhaps this is my primary issue.
Original post below:
I'm using AndroidX Espresso 3.1.0 along with ANDROIDX_TEST_ORCHESTRATOR. The only issue I have is that when I run shards (to speed up test runs), it sometimes decides to fail for no good reason.
For example, I open three terminals and three emulators. I run one of these in each terminal to kick off three separate shards:
ANDROID_SERIAL=emulator-5554 ./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.numShards=3 -Pandroid.testInstrumentationRunnerArguments.shardIndex=0
ANDROID_SERIAL=emulator-5556 ./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.numShards=3 -Pandroid.testInstrumentationRunnerArguments.shardIndex=1
ANDROID_SERIAL=emulator-5558 ./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.numShards=3 -Pandroid.testInstrumentationRunnerArguments.shardIndex=2
This then runs a third of my tests on each emulator. So good so far. After a long time, they're all done and I have a nice HTML report telling me zero tests failed. I haven't touched my code, I haven't touched the emulators. I go to touch each of the terminals. In each I hit the up arrow to grab the last command ran in that terminal, and then enter to rerun exactly what I just ran. Two of the emulators are fine and run through all their tests. The third does not, and gives me this error message below:
> Task :<snip>:connectedInternalStagingAndroidTest FAILED
[no message defined]
java.lang.RuntimeException: com.android.builder.testing.api.DeviceException:
com.android.ddmlib.InstallException: INSTALL_FAILED_INVALID_APK
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1431)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: INSTALL_FAILED_INVALID_APK
at com.android.builder.testing.ConnectedDevice.installPackage(ConnectedDevice.java:132)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:147)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:59)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
... 4 more
Caused by: com.android.ddmlib.InstallException: INSTALL_FAILED_INVALID_APK
at com.android.ddmlib.Device.installRemotePackage(Device.java:1031)
at com.android.ddmlib.Device.installPackage(Device.java:902)
at com.android.ddmlib.Device.installPackage(Device.java:880)
at com.android.ddmlib.Device.installPackage(Device.java:869)
at com.android.builder.testing.ConnectedDevice.installPackage(ConnectedDevice.java:126)
... 7 more
Why? How? It doesn't make any sense. I hit up and enter again and then it happily runs through all the tests without issue.
My problem is that this random failure happens enough I can't set up my machines to use sharding, and therefore cannot speed up the test running process for my team.

Android Studio - Empty report when running local unit tests

Im running local unit tests (located under src/test/java) either by clicking the verification/test gradle project or from the command line "./gradlew test --continue". When the execution completes with failed tests i get the following message:
What went wrong:
Execution failed for task ':MyProject:testDebug'.
There were failing tests. See the report at: file:///Users/asaf.k/AndroidStudioBranch/MyProject/build/reports/tests/debug/index.html
But when i examine the html file it is always empty
Why ?

Jenkins unable to locate files on my computer

when ever I try to build my android project on jenkins it fails by saying :
Started by user anonymous
Building in workspace /home/tanzeelrana/git/eventmatrix-cordova-app/mysteryshopper_version2
[mysteryshopper_version2] $ ant -Dlabel=trial1-9 clean debug
Buildfile: /home/tanzeelrana/git/eventmatrix-cordova-app/mysteryshopper_version2/build.xml
BUILD FAILED
/home/tanzeelrana/git/eventmatrix-cordova-app/mysteryshopper_version2/build.xml:90: Cannot find /home/tanzeelrana/android-sdk-linux/tools/ant/build.xml imported from /home/tanzeelrana/git/eventmatrix-cordova-app/mysteryshopper_version2/build.xml
Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
on line 90 in my build.xml file I have a tag with the following in it :
import file="/home/tanzeelrana/android-sdk-linux/tools/ant/build.xml"
does anyone know why it is unable to locate this file ? the file exist at the exact path ....
Jenkins usually runs with its own user (jenkins),
so it is probably an issue of permissions.
Try printing the current user from within your Jenkins job.
EDIT:
See here about running Jenkins as a daemon -
it also shows how to set it to run as a different user than 'jenkins':
Installing Jenkins as a Unix daemon

Categories

Resources