I am wondering what is the fastest way of making quick simple unit tests for methods in InteliJ idea during android development. Do we need to test it via device? Is it not faster to do this tests in other tool without this slow android-device(or emulator) usage? Any up to date resources would be usefull.
There is an approach to make 'logic library' as a jar. Then you can test it using simple JUnits.
I don't know the better way for Graphics, layouts, etc than using real devices and emulators for screens you don't have access to.
Related
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.
I created an application with xCode and Objective-C for iOS. What is the best way to create an android app similar to the iOS one?
Is there any application for the same purpose?
My app has dependencies of
Calayer
Bizerpath
App delegate and protocols
Run time blur
absolutely not
because they are 2 different thing
i think you have to write android version from scratch
You can rewrite the app for Android.
An alternative is to use a tool, like https://code.google.com/p/objc2j/
http://objc2j.googlecode.com/svn/
I did not try it. Anyway, if you use the tool, then make sure you test all the features. It might be cheaper to rewrite it, but this is a management issue.
So I've been working with Eclipse for Android for about a week now. Coming from a Visual Studio background, as well as a partial Eclipse background, I've never programmed anything for the Android environment before. So I was wondering, especially if there is no one answer, how do you test the "little things". Let me explain, if I've made a class and I want to test that all the elements would work, normally in other IDEs I could simply use a "Main" to test if a class or function was working the way I want it to work. However, the only way I can think of to make a similar result would involve making a test or debug activity in the App itself and running it that way. Is there a simpler way do testing quick things?
TL:DR
Im using Eclipse for Java Android, never have before, is there a way to test if a function or class works without having to use the Emulator or run it on an actual Android device.
If you want quick feedback that something works, there are various ways to do it.
The number one way is to build unit tests. This is just writing code that test your production code. Once of the reasons this way is highly favored is because once you build a unit tests, you have that unit test forever and can execute it pretty easily and quickly. This is great for regression testing. I use Junit to build out unit tests in my own classes, that are separate from the Android framework. The Android framework provides a number of great resources to tests stuff inside that framework.
However, if you decide unit tests aren't for you, the next best way to get quick feedback would be to use the Log class that Android provides. This just prints some statement to the logcat file of the device.
You run your code in the simulator and/or a device, and check if everything works :)
Btw, just a friendly advice - Don't use eclipse, go straight to Android Studio.
Eclipse has waaaaaay too much bugs, and Android Studio is becoming better and better by the day.
If you want to have a similar "main" method type of testing, you could do the same with Android development simply by putting your test code in the onCreate() method of your main (launcher) Activity. Then fire up the app in the emulator or a device.
I believe that you can help me solve problem connected with compabitility JUnit libraries.
The problem is that we develop mobile apps (android) and we're using test managment tool called SpiraTest. We want that unit test results will be exported to SpiraTest automatically so want use junit extension for Spiratest (made by Spira team). Problem is that it requires JUnit4 to integrate, what Android doesn't support.
What would you recommend to do?
I would say that if you are going to do unit testing of you own functionality it won't really matter if Android supports it or not, you just run the unit tests regardless of the Android SDK. However if you intent to use jUnit to work alongside Android, there is no way at the moment to do it that I'm aware of.
I'm interested in developing android applications. I've a background of Java/Swing/C++/ajax developer so I think I may find myself at home. As I installed the SDK I noticed that I can't follow my usual java development scheme: building base libraries, then the final app. In fact I'd like to develop libs and test them in a more convenient environment like, Swing. There is no way I can use android libs in pure swing apps...
Do you have any suggestion about these topics and what's your development process?
If you have written a lib that does call functions from the android jar, you can write JUnit 4 tests in a separate Project and execute them to test your lib functions. This forces you to keep some of your functionality separated from the android specific things and you can then be sure that all the errors you tested for are gone before you introduce the problems that can arise if you are running on the device. You can do JUnit Tests on the emulator too but that is a little bit more complex.