Automation testing in Java or Android possible - java

I am working on writing automation to test hardware (Wi-fi, Ethernet, Bluetooth, GPS and keyboard). Nothing is automated its all manual testing at the moment. the product will load a live USB OS and from there it will run a application. I need to write Java code which will launch the application, selects the proper options and spits out the pass or fail results. This all things needs to be developed in Java if possible or Android, I am not sure if I am allowed to use any existing third party tool.
If this is possible to write on Java or Android are there any tutorials or if there any third party suggestions I appreciate information in general about this if this is at all possible and where to look for this information.

What you are looking for is Cucumber framework. It is a framework which automates the testing for you. You write some calabash/ruby scripts and open up a port on your network and Cucumber takes care from there on.
Check this link: https://github.com/cucumber/cucumber/wiki
Also see: http://cukes.info/
Also search for the cucumber_book by Matt Wynee if you can get one. It is a real good reference.

Related

Appium vs Espresso for automated testing framework

For last few weeks, I was using Appium(python) for android testing but yesterday we have decided to shift to Expresso(Java) for automated testing. There are couple of reasons why we are making this shift:
We want to scale out our automated testing, and there are lot of features not present in appium.
This is one of the latest testing framework for android, and has nice backward compatibility.
Small API and very easy to customize.
I have been reading for Espresso but I don't find anything great at all, If I compare it with Appium. I am a Python/R developer so maybe there are couple of points I am not able to understand. Would anyone like to help me understand if the shift to this new testing framework will be good for future? I am missing the bigger picture here, and any help would be greatly appreciated.
The Shifting will be very much useful as Espresso supports testing activities outside the app like camera, browser and dialer etc which appium does not support.
Espresso you can test toast message, auto complete and dialogs which are outside app.
With Espresso Test Suit you can find code coverage and measure your testing efforts.
You can go to Espresso if you're sticking only to Android automation and have no idea of automating iOS.
AFIKW, Espresso needs source code of the app in order to automate it.
Advantage is, it's directly open-sourced by google.
But my go is to go with Appium since its a large open sourced community with huge enhancements on its way and easy to automate with any programming language and needless to say it supports both Android and iOS.
I agree that Espresso may be be very efficient when it comes to Android testing solely. For example, it can run only the activity it's testing, which is great.
Still, I stick to the Appium because it has the same API for both AndroidDriver and iOSDriver. Usually Android apps are accompanied by iOS apps, and if you're responsible for the UI automation, you have to take overall costs into account.
Appium has following advantages over platform-specific solution:
Android and iOS tests can share many classes, including helper methods and configuration,
Android and iOS tests can share common tests logic on higher level, while having different or slightly different implementation on lower level (for example sometimes I can just copy whole page object class and make simple change of locators in order to make it work on the other platform),
same API enables us to seamlessly switch between the iOS and Android test development in a team. Easy switching to Selenium for Web development is additional benefit.
The biggest disadvantage of Appium is the speed of longer test scenarios and some difficulties in locating elements, but still it's my choice.
As the side note, I'd like to add that you shouldn't forget about the test pyramid which refers to test automation. Please keep balance between Unit Tests, Integration tests and UI tests http://martinfowler.com/bliki/TestPyramid.html
The main difference between the two is,
Espresso test is within the application and it is aware of all the layers of the application. So you can mock certain layers of app, more like a white-box testing
Appium tests are black-box, tests know only the UI layer of the app. Main advantage is for cross-platform testing.

How to integrate programs written in different programming languages?

I have two developers in my team. One will develop a Python application, the other will develop a Java application. The Java app generates a boolean value which is used by the Python app.
How can I integrate these applications? I have thought about using:
Return codes: Python app calls the Java app, then the Java app uses
the return code to inform the boolean value.
Sockets: Connect both
applications through sockets and exchange information. I think this
is overkill.
Files: The Java app does its stuff, writes the output to
a file, then the Python app reads this file and retrieves the boolean
value it needs.
Any other suggestions? I'm not just looking for a solution, I'm also considering here aspects such as code organization and "beauty" of the overall solution.
Edit 1:
Thank you #user2387370 for the recommendation of using Jython, but I can't use it.
Edit 2: Thank you #RickyA, I'll have a look at messaging systems (such as zeromq, which you mentioned).
Use a messaging system like zeromq. That has libraries for both languages and allows you to integrate them seamlessly.
Your proposed options will get clunky interoperability. (filelocks, dead sockets, dead processes etc..)
Also this page lists some tools that can be used for pyton/java interop. I can't recommend one since I used none.

How to extract Java Android sources and integrate in another project

We are developing a java based framework, running on Linux OS
that will provide an infrastructure for developed Applications (Java)
which is very similar to Android OS architecture.
Our framework consists of services and data providers running as different processes and providing
data to the applications running also in the system.
We want to use frameworks/base sources from the Android OS and use it in our framework
after some modifications, without building the entire Android OS.
Is this task possible to achieve in a reasonable amount of time?
If so, can you please point us where to start?
Thanks
If you want to modify a portion without needing to rebuild everything i think you could trying using AOP and compile time weaving, that is AspectJ in your case. Have a look here.

What are the limitations of Python on Android?

I am getting ready to start a little Android development and need to choose a language. I know Python but would have to learn Java. I'd like to know from those of you who are using Python on Android what the limitations are. Also, are there any benefits over Java?
Most of the points mentioned by Andrew stand, I just wanted to mention that python can be and is used for full fledged Apps published on GooglePlay and even iOS. I can't speak for other frameworks but here are some examples of Apps published using Kivy.
Process Craft Google Play iOS
Fantasy War hammer
PreseMT is a multitouch presentation maker
Memo robots
Ground Truth
Kaleidoscope
Showcase demo example from Kivy project
DefelectTouch game iOS
Bargenius and many more...
On Packaging we have tried to make it as simple as possible, we also provide
A pre-built VM that can be used to make your apk with you having to do nothing except
copying your project dir over and running one command.
On GUI, yes the ui is custom, by default(tries to match Android's Holo theme). However it can be customised to resemble other look and feels, although I haven't tried it personally.
Oh and as long as one is talking about python based apps on android, I found this project mentioned on stackoverflow PyMob, their apps page mentions some interesting apps .
I investigated this recently for similar reasons. My conclusions were that I could not use Python to develop a native-looking application, which is what I wanted at the time. Specifically:
Python can't receive callbacks from the Java UI classes, so you can't use any native Java UI elements such as ListView, etc. Only dialog boxes etc. are easily available. If you have a totally custom UI such as a game, you can try PyGame for Android, or you could look at Kivy, which also uses PyGame.
Packaging of Python applications is very difficult, especially because the Python interpreter is not included on Android by default. The Kivy and PyGame teams are making some intermittent progress on this.
Because of the aforementioned issues, Python is essentially never used to make full fledged applications published in the app store, and so the literature on how to handle the many sundry issues with SL4A (Scripting Layer For Android) is very thin.
So, if you want to make an application that uses native UI elements, that you can actually distribute in the Play Store, or both, Python is regrettably not an option.
I have developed Android Apps on the market, coded in Python. Downsides:
Thus far my users must download the interpreter as well, but they are immediately prompted to do so. (UPDATE: See comment below.)
The script does not exit properly, so I include a webView page that asks them to goto:Settings:Apps:ForceClose if this issue occurs.

How do we test our Java UI?

We're looking at record and playback type test tools to automate some of our UI functional testing.
We've looked at most of the usual suspects from Silke to QTP and none of them work.
They all fall over when a right click is required to select something off a right click menu, or when you have to choose a value in a drop down list in a grid.
Does anyone know any tools that can handle this type of UI?
We have made good experiences with Squish. You can identify UI elements by IDs or record mouse actions.
Are you talking about a stand-alone Java application, or is it web-based, with Java on the server, but HTML delivered to the client?
Assuming it's a stand-alone Java application, SilkTest and QTP ought to play nicely with Java. (Are you using the appropriate Java add-in/plugin for Java support? QTP has a separate add-in for Java support.) Another tool to consider would be IBM Rational Functional Tester. It's built in Java and works well with Java apps. I've used all 3 tools, though never SilkTest on a Java app. In my experience, both QTP and RFT performed well with Java apps.
That having been said, on every test automation project, there are going to be UI controls that do not work great out of the box with the selected automation tool. (3rd party controls are usually the culprit). In these cases, you will need to manually code a work-around. In the example of right-clicks not working as expected, I have often needed to forego clicking to select an item from a right-click menu in favor of using keystrokes to select the desired item. What this really points to is that you have to let go of the notion of record/playback being an effective means of automation.
Additionally, it might be instructive for you to post the actual code that was recorded, and at which line it fails to select the item in question. The actual script code could give me some clues as to what is actually going on.
Sahi is good option for recording and playback like testing stuff.
Here is a sample tutorial.

Categories