I have come to know about TravisCI. It's great for testing syntactical bugs and resolving them but if that's the only functionality it provides, then I think Travis isn't worth it for testing. My only question is, does TravisCI automatically tests the code for exceptions/errors which might occur when the user is using the app? Are their any pre-requisits for this?
I'm worried that I understand your question correctly.
TravisCI is a combination of builder and test runner, not a monkey-testing program. You need to write code for Andoid unit-test and autonomous UI test based on your service logic, and also need to use additional app feedback program if you want to get information(stacktrace) of some error occured from users.
To write a unit test, see the official Android tutorial at below link.
https://developer.android.com/training/testing.html
Also, you can command monkey testing.
http://developer.android.com/tools/help/monkey.html
And, in order to get error feedback, there are many projects and services to do this. Android Play Store developer console provides in ANR & Crashes menu. Or, Crashlytics provides errors in more arranged manner. Consider ACRA if you are in a security-sensitive company as it allows you to install to your own server. When user got crash, stacktraces will be automatically collected.
Related
I've a simple Android app on which I'm depending on n number of libraries by adding them to my dependencies list in my Config file. Sometimes the changes done in the dependent library causing my app to crash and making it non-installable (means it is producing some runtime crash due to bug in their code) and making my app uninstallable.
Is there a way to find it during build time by running a test suite on my app to find this breakage. It's really hard to manually test them each time for each and every minor release.
I'm quite new to Android space. So, I've no idea whether this is achievable or not. It would be helpful if someone could provide a pointer to this.
If you feel the question is too naive or stupid suggest me in comments to add more details on what.
How do I combine a standalone Java application with an Android application?
I have a piece of code taken from the Google quick start examples that perform a task that I can't seem to be able to combine with my activity source code.
I'm of course talking about the following Google example: Sheet API, if I just add it as a standalone class and tell Android Studio to run this application, before my Android application, then it will produce what the code is suppose to do.
If I try to copy and paste the exact code into one of my activities it will give a couple of problems. One is that it can not find my keystore, another is a threading issue which I understand, another being that it can not find the credentials (even if the file is present), the newTrustedTransport-method call will be an issue, the setDataStoreFactory-method call will be an issue, file creation even with the correct uses-permissions and so on.
What is going on in the background that would make exactly the same source code work in one instance and not the other? What do I not know about Android Studio, and how an Android project works in the background for me having these issues?
I had an idea that I could just keep this standalone application as it is and store a file with the result that this Sheet example would provide me. But, since I do not have enough experience with Android Studio I have no idea if the result will be available for the actual Android application once it was made into a release. Will it? I can't save the output file generated by the Sheet example, under the res-folder, under the app module for some reason (scope?).
With other words... Can I have a standalone application, that is tasked to run before the Android application, to gather data and it will be doing this EACH time the Android application is run on a client? I feel like it would be stupid if the IDE would present this like this would actually work but then when the application is made into a release then the standalone application will not "follow" and be part of the release...
If I could just combine the source codes, I will not be having this issue at all. No examples online, neither Github or Youtube can provide me with answers on how to do this. Many examples online provide me with source code that is either out of date or just not what I'm looking for, and I really hate Google's way of explaining things. Just look at how they give code examples under this page: Google API Client Library for Java, and not give a full example where they would fit into the a project. Maybe all I need to make everything work is to use the code under "The library runs on Android 4.0 or higher (#Beta)."
I want to access running services or apps like clean master is showing, please guide me.
From - Android - getRunningservices(ActivityManager) deprecated
We deliberately don't have an API to check whether a service is
running because, nearly without fail, when you want to do something
like that you end up with race conditions in your code.
Context: I am working with a project that involves an android-controlled hardware and an iOS app that talks to that android device via websocket. We are in a good shape in terms of lower level (API, unit, contract) testing, but there's nothing to help us with the UI part of it.
UI automation, especially end-to-end is not my favorite way of testing because it is flaky and slow, and I believe it's purpose is only to guarantee that the main user flows are executable rather than every single piece of functionality.
So I developed a suite that includes both the android and the iOS code and page objects, but right now the only thing I can do is run each one of them individually:
Start the appium server and appium driver for android, run the android app suite
Start the appium server and appium driver for ios, run the ios app suite
But that is not quite exactly what I want - since this is going to be the only test case, I want it to be full end-to-end; starts appium server, starts android server, also start appium drivers for both, run test that places an action on ios and verifies that android is executing it.
I don't want to have someone manually running this thing and looking at both devices. If this doesn't work, android and ios suites are going to run separately, relying on mocked counterparts.
So I am throwing it here to the community because none of the test engineering groups I posted to were able to come up with an answer.
I need to know if anyone has ever done or seen this to shed me a light, or if anyone knows how to do it.
Can Steve Jobs and Andy Rubin talk?
I would look into starting 2 appium instances via command line on different ports and then connecting each suite to a given appium instance. Then at this point you just need to properly thread each suite so that you can properly test your code. To do that you will need to add dependencies (can be easily done using TestNG).
Steps:
1) Create a thread for IOS and Android Suites
2) Run each suite on a different appium session (aka different ports)
- You will need to know how to run from command line for this
3) Setup your tests to depend on one another (I recommend using TestNG as the framework)
4) Use threading logic to properly wait for tests to finish before starting. Yields and Timeouts will be very useful, as well as TestNG dependencies, it will save your life given what you are doing.
NOTE: Appium has a timeout functionality where if a session does not get a command in 60 seconds by default the session is destroyed. AKA make sure you increase or find a way to turn off that timeout.
Additionally as a recommendation I would advise the use of TestNG over JUnit. JUnit is a Unit testing framework, meaning you are testing specific functional units. This however is not ideal for app automation as many areas of an app depend on prior functionality. For example if you have a login screen where the login functionality is currently broken you don't want to run all of the tests the need the user to be logged in to pass. This would cause not only a lot of fright when a large portion of your tests fail, it will also make it harder to track down why it failed. Instead if you have all of these tests depend on the login feature passing then if the login fails there is a single error which can then be fixed, and all the tests that depend on the login feature don't run when you know they are going to pass.
Hope this process helps, sorry I obviously can't send out code in this as it would take hours for me to type/figure out.
Problem solved, it was as simple as it looked like.
What I did was to implement an abstract class that builds drivers for both android and ios with their capabilities and specific appium port, instantiating their respective page objects as well. All the test classes extend this abstract class.
Then I divided the suite in 3 pieces:
One for the Android only, which only accesses the page objects for android;
One for ios, which also accesses only the page objects for ios;
And a third test that spins up both ios and android and controls them both.
To avoid always starting two appium servers and also avoid always downloading the latest app versions for both android and ios I created gradle tasks for each platform, so the CI jobs can call only the task that prepares for the platform it has to test at a given moment.
I'm not sure this question belongs to SO since it is maybe to broad, but I don't know where to ask it (I did not find a better stackexchange site).
Context
I'm using UiAutomator to write some Ui test on android. I created some functions to simplify the write of the tests like the one in the doc
public void startMainActivityFromHomeScreen() {
/*Start the app from the home screen*/
}
As a developper, this works fine. But non technical peoples (contracting owner) can't easily use this functions to write tests.
Needs
I'm searching for a way for non technical users to write some scripts using the function I already defined. Here is a dummy example (both script format and actions)
Suite: Launch the app twice from the home screen
Case: Launch the app for the first time
Do startMainActivityFromHomeScreen
Expect ...
Case: Launch the app for the second time
Do startMainActivityFromHomeScreen
Expect ...
The important point here is to interact with java functions. I know other tools like calabash but it does not provide java interfaces.
Current approach
Here is an idea (nothing implemented)
Put all the functions in a lib
Write a groovy dsl (because groovy interact well with java) which allows non technical users to easily write scripts
Create a java program which will evaluate the groovy script and generate the android code source associated (with the lib (from (1)) as a gradle dependency).
Run gradle androidTestCompile
Since the functions are in a lib, developers can easily include and use it into their projects. So the same lib can be used for all users.
I hate this idea since I have to generate code source from my code, but this is the only one I have.
Questions
Is this approach as horrible as I think it is ?
Do you know another way to do it ?
I'd check out https://cucumber.io/docs/reference/jvm#java, it's a library that accomplishes pretty much exactly what you're looking for by letting you associate regex's with Java test methods.
Your Java code would look something like:
#When("^I open the app from the (main|home) screen$")
public void openApp(String launchScreen) {
...
}
And the testing file would look like:
Feature: Launching app
Scenario: Launching from first screen
When I open the app from the main screen
Then I see a blue icon...
Scenario: Launching from second screen
When I open the app from the second screen
Then I see a green icon...