Android testing on multiplie devices from Jenkins - java

I'm running Espresso test to test my application. The app have a first time login that requires a code from a text message.
The easiest way to get past the the first time login is to keep the same application installed so that the user data remains.
running the command:
./gradlew connectedAndroidTest
seem to remove the application when the tests are done. Is there any simple way to skip the uninstallation part and just run the tests on all connected devices?
Thank you.

It is strongly recommended that you not rely on state being already setup on the device, but instead, setup the state you need within the test itself.
That being said, you can install the app with gradle and the run the tests with adb.
This assumes a standard default app layout and setup, using androidx.test with a recent version of the android gradle plugin.
First install the app and the tests.
./gradlew installDebug installDebugAndroidTest
Then you can execute the tests:
adb shell am instrument -w com.your.applicationId.test/androidx.test.runner.AndroidJUnitRunner
This will run your app and keep your app and tests installed.
You can run the adb command multiple times in a row and it will execute the tests without rebuilding and reinstalling your app.
Of course, if you make any changes to the app or tests you will need to re-run gradle.
More info:
Installing adb
Running tests with adb
androidx.test
Customize your test run

Related

automatically run external application, which use Cucumber for testing main application

We have application which use Cucumber framework for testing our second application, the applications runs on own processes (black box testing), currently we do following steps:
1) Run DB
2) Run main application
3) Run test application which use Cukumber framework for testing main application
Question is: how we can do this automatically by using TeamCity ?
Create a Command Line build step:
Point to the working directory
Run your Cucumber tests from the command line. Example.
Here is more info on Cucumber's CLI.
My approach would be to write a script that sets up all dependencies. I.e. starting the database, starting the second application and then run the Cucumber stuff. The script would be possible to run on the CI server, i.e. TeamCity or on a developers system so it is easy verify that they didn't break anything before committing.
Restricting the execution to TeamCity only would not be my preferred approach.
This lead toa solution taht depends on your dev and CI environment. Are you running on Windows or on Linux? The scripts will different depending on the operating system.

Set up a local/remote test server to automatically run automated Robotium tests in Android studio using a Task Schedular

The problem I am experiencing is having to execute the test cases within Android studio using the Run -> Run "Tests" method or adb shell am instrument method. I would like theses tests to be run automatically using a Task Scheduler without any input from me.
After some research I found that to make this possible is to build a Test server, and use a Task Scheduler and start a log file that will help to document the test results of what is being tested in the android app.
The Automation tests should also automatically pull the project's latest source code(Programming language used is Java).
How can I achieve all of this within Android Studio?

Exported APK Not Working

I've just published an app of mine to the Google Play Store and it seems that it keeps force closing and crashing on the users.
I am not asking for a solution as to why, but i am curious.
On eclipse i have the Emulator and the target API of my app was Android-19 (it's 17 now because i'm changing that to see if it'll help). And while in eclipse and while running the emulator, with several devices (tablets, nexus one and such) , and the app works perfectly fine.
My friend has sent me a screenshot and the message that comes up once they try to open the app is "Unfortunately, Data Tool has stopped."
Any brainstorming ideas?
-Colt
THIS ISSUE IS NOW FIXED!
Here's a way to locally test your app's release APK outside of Eclipse. It's written for Linux, but should be pretty close for other development hosts.
adb uninstall my.package.name; adb install -r my.package.apk && adb shell monkey -p my.package.name -s 0 1
This assumes the simplest case where you only have a single device connected. If you want a more versatile version that allows for easy switching between devices and/or versions, let me know and I'll add it.
Try building it without proguard first and test. If that works then its proguard configuration file issue.

How to auto reload app engine dev server?

Im following the tutorial on the App Engine website for 'Google Cloud Endpoints' in Java. Everything works fine and I can run the development server using mvn appengine:devserver. The problem is that when I make any changes to a file (for example, any java file) the dev server doesnt automatically recompile. I need to ctrl-c to kill the dev server and restart it for every code change I make.
Is there a way to have maven automatically detect changes to any files in my project and have it automatically rebuild and restart the dev server?
Unfortunately no. If you want this behavior on your dev server, you need to use Python.
I run in the same issue and there is no real workaround provided by the App Engine to help you doing this.
From the "Using The Google plugin for Eclipse":
With Eclipse, you can leave the server running in the debugger while you make changes to source code, JSPs, static files and appengine-web.xml. When you save changes to source code, Eclipse compiles the class automatically, then attempts to insert it into the running web server dynamically. In most cases, you can simply reload the page in your browser to test the new version of the code. Changes to JSPs, static files and appengine-web.xml are recognized by the development server automatically, and also take effect without restarting the server. If you change web.xml or other configuration files, you must stop and start the server for the changes to take effect.
(https://developers.google.com/appengine/docs/java/tools/eclipse#Running_the_Project)
There is NOTHING comparable in Java (link from "The Java Development Server") (https://developers.google.com/appengine/docs/java/tools/devserver)
There's currently nothing in the App Engine SDK to automatically restart when files change, but that's not to say you can't do it. I ran into the same problem and wrote up a script to listen for file changes as triggers to restart App Engine. It's in JavaScript, so you'll need to install Node.js if you haven't already.
// Install watch-exec
$ npm install -g watch-exec
// Watch the current directory
$ watch-exec --command "mvn appengine:devserver" --watch .
This will immediately start App Engine, and then restart it any time a file changes. If the app crashes for some reason, the script will wait for your next edit before trying to restart.
P.S. That entire script is about 40 lines of code, and you could probably do the same thing in other scripting languages. If you haven't tried writing your own automation before, I'd definitely recommend checking out the source code to see how this works.
I've found using Gradle, GAE, and Spring MVC, the assemble command will put the correct artifacts in place, and the server will re-init the app. It's a little quicker than a server restart.
Using App Engine standard with the cloud.tools appengine-maven-plugin hot swap works fine (most of the time, can be problems when setting up the workspace).
For a multi-module maven project: no need to stop the server or browser,
just push the code changes (maven command package -pl *-server)
& refresh the browser.
Debugging with a debug client currently works perfectly for changing / adding code within methods.

Running selenium automation tests on remote teamcity build agent

Recently we started using Teamcity for build management and to run selenium junit tests using ANT scripts. The tests are running successfully and shown as passed on teamcity console.
When the tests are running if I login to the build agent machine, I was expecting to be able to see the browser window open and fields getting populated and submitted. I don't see the Firefox browser window open, wondering how my tests are passing. When I run the same test scripts in Eclipse, the Firefox browser window is opened and the web page fields get populated.
Appreciate your comments.
Because TeamCity build agents are run as a Windows service. So you won't be able to see the actual GUI.
If you want to change it, please change your build agent installation.
Installing and Configuring the TeamCity Server
How can I run a Windows GUI application on as a service?
Selenium Tests run in the background when TeamCity CI is run as a Windows service
Running Automated GUI tests with TeamCity

Categories

Resources