Mono for Android: Which Testing Frameworks work - android

I have created a Mono for Android VS2010 project and added NUnit tests.
It seems Mono for Android does not support NUnit according to this post from Xamarin:
https://bugzilla.novell.com/show_bug.cgi?id=644813
Are there any testing frameworks that do run when in a Mono for Android project?

no, nunit does not work nor do any other frameworks. the intent of monodroid and monotouch is to provide a .net development environment that allows you to easily port business logic between different environments. as a result you can't really test android/ios specific code, but you can test generic .net business logic code. in the monodroid projects that i write, i create 3 projects in the solution, one is the android project, another is a .net library that holds all of my non-android specific logic and the final project is a nUnit test library against the .net library. I then add my logic code files into the android project with linked files. monodroid project files can not be tested, but .net codes files linked into monodroid projects can be tested with what ever framework you choose.

There is now a Mono for Android test runner for NUnitLite (0.6). This allows you to run some (or all) your unit tests inside the emulator or on device(s).
It's very similar to Touch.Unit which provides a runner for MonoTouch on iPhones and iPads (iOS) and feature parity is planned (i.e. adding the network logging).
Disclaimer: I wrote the runner (but the most interesting code is NUnitLite and the, several times forked, MonoDroid.Dialog library ;-).

For UI testing on actual devices, LessPainful announced earlier today that Calabash for Android supports it since version 0.1.0:
[...] we now support Mono for Android.
[...] Currently you can only test Release builds of your app. If you need to test Debug builds let me know.
I've not used Calabash with Mono.

I created a version of NUnitLite that targets MonoDroid.
It's worked quite well for me so far.
It needs to run directly on the emulator or device at the moment. If someone were able and inclined to write a runner for it, I'd welcome the input.
Check it out here: https://github.com/SpiritMachine/NUnitLite.MonoDroid

Related

Call C++ executables insider Android

I am now porting a linux C++ library to Android using JNI. The library porting itself is very straightforward, and I have built a C++ library that can be invoked by Android via JNI. Now my problem is to verify that the library works well in Android environment as well. In the linux development environment, some unit-tests and regression tests are already available. So I was wondering whether I can test the library by taking advantage of all the available unit-test and regression test programs. For example, in linux I have the following binaries:
mylib.so
my_unit_test
my_regression_test
Then for Android, I will first built mylib_android.so. Then, can I build my_unit_test_android and my_regression_test_android for Android platform? If it possible, how can I invoke them in the Android simulator and the real device?I have little knowledge about Android, and any ideas will be appreciated.
Transform them to libraries with single function and write Android app that will use them.

Port .NET dll to different platforms

I have a dll based on .NET 2.0 with full source code access.
So I can build it in VS2010.
I need to port this to Android/iOS/MacOS.
As a result I expect some equivalent of dll for each platform.
So another programmer can link (doesn't matter how) this equivalent to his own project at one of that targeted platform.
For example I ran MonoDevelop on Mac and don't see how I can build my .NET project and to receive such equivalent of dll.
So I need help to find solution and understand what to do to receive requierd result.
There are CLI implementations, primarily Mono, that work on both iOS and droid. The simplest tools here are MonoTouch and Mono for Android, both available from Xamarin. With these tools, you can build and test your dll targetting the relevant frameworks. Another programmer, again using the MonoTouch or Mono for Android tools, can reference those dlls, and build their application, with all the tools necessary to package and deploy (side-loading or via, say, the device's store) an application using that library. This deployment will typically also include all the runtime/framework pieces needed by the application.
MonoTouch makes use of the MonoDevelop IDE, so will be familiar to you as a MonoDevelop user. Mono for Android can do that (i.e. be hosted inside MonoDevelop), but can also be used inside Visual Studio.
Running .NET code requires a .NET runtime to be installed. Neither Android nor iOS devices come with such a runtime preinstalled.
In theory, you could install the Mono Runtime (a open-source .NET alternative) on an Android device or a jailbroken iPhone/iPad. However, as I understand it, you're looking for a way to create a library to give developers, so this isn't a good solution.
However, what could work is creating a library with MonoTouch. MonoTouch compiles your .NET code to a binary that iOS devices can use - regardless if they're jailbroken or not, without needing a runtime installed.
If you follow best practices, you might port your library successfully, such as
http://sharpsnmplib.codeplex.com/discussions/390251
However, it purely depends on the characteristics of your library, which you does not mention yet.

How to create Android apps using Delphi

I have been asked to research on how to make an android app using Delphi, Now I am not sure that this can be done. I have not come across tutorials on the same. Somebody please clarify on this issue.
Delphi cannot create Android apps at present. This is being worked on for a future release.
Update: As of the release of XE5, Delphi now supports Android development for certain ARM hardware using the mobile Delphi compiler.
Free Pascal is now able to produce code for the Java platform - so it might be feasible to create Delphi code which can be compiled to Java bytecode with FPC and then converted for the Dalvik VM.
The FPC backend for the Java Virtual Machine (JVM) generates Java byte
code that conforms to the specifications of the JDK 1.5 (and later).
While not all FPC language features work when targeting the JVM, most
do (or will in the future) and we have done our best to introduce as
few differences as possible.
This FPC JVM backend is not related to Project Cooper by RemObjects,
nor does FPC now support the Oxygene language.
Two choices to follow at present - check out Delphi for Android which is in design/beta phase: http://lenniedevilliers.blogspot.com/
Or, use Prism http://www.embarcadero.com/products/prism (and check out their Oxygen for Java coming soon http://www.remobjects.com/oxygene/java.aspx which is in Beta)
With DWS as backend script compiler and the soon to come Smart Mobile Studio (aka OP4JS) component library and RAD interface it will be possible to make apps running with HTML5 in android applications (and iOS or any other html5 compatible system).
By using object pascal, all Delphi and freepascal users will have a short learning curve and a high code reuse factor.
There are some samples using only the DWS backend here :
taming-the-flock-with-object-pascal
taming-html5-verlets-with-object-pascal
Update :
More samples can now be found on their homepage.
First steps with native Android applications made with Lazarus/FPC are here.
One way is to use a combination of Delphi, Sencha and PhoneGap by leveraging the Raudus framework. You can try the RaudusEmployee.apk example on your phone and see if this method will work for you.
http://www.raudus.com/samples/
This is not a native application, but similar to many new HTML5 applications.
Delphi XE5 is now released with Android support.
http://www.embarcadero.com/products/rad-studio/create-android-apps

JUnit and Android?

Is anyone using Junit and Android? Or is that just a worthy hope? Is there a tutorial anywhere?
Android has great support for JUnit 3
From Testing Fundamentals on Android Developers:
The Android testing framework, an integral part of the development environment, provides an architecture and powerful tools that help you test every aspect of your application at every level from unit to framework.
The testing framework has these key features:
Android test suites are based on JUnit. You can use plain JUnit to test a class that doesn't call the Android API, or Android's JUnit extensions to test Android components. If you're new to Android testing, you can start with general-purpose test case classes such as AndroidTestCase and then go on to use more sophisticated classes.
The Android JUnit extensions provide component-specific test case classes. These classes provide helper methods for creating mock objects and methods that help you control the lifecycle of a component.
Test suites are contained in test packages that are similar to main application packages, so you don't need to learn a new set of tools or techniques for designing and building tests.
The SDK tools for building and tests are available in Eclipse with ADT, and also in command-line form for use with other IDES. These tools get information from the project of the application under test and use this information to automatically create the build files, manifest file, and directory structure for the test package.
The SDK also provides monkeyrunner, an API testing devices with Python programs, and UI/Application Exerciser Monkey, a command-line tool for stress-testing UIs by sending pseudo-random events to a device.
This document describes the fundamentals of the Android testing framework, including the structure of tests, the APIs that you use to develop tests, and the tools that you use to run tests and view results. The document assumes you have a basic knowledge of Android application programming and JUnit testing methodology.
I have been using Roboelectric which is awesome because it does not launch the simulator making the run time for the tests very very quick. A sample project is provided as an example and can be found here at github
You can also use Robotium to drive the UI from within JUnit for more functional style testing.
"Note that the Android testing API supports JUnit 3 code style, but not JUnit 4." (Source)
If you want to use JUnit4 or have existing JUnit4 tests you can use JUnit4Android.

Can Android use standard built JAR files?

Im pretty sure the answer is no, but im using the new IntelliJ EAP version and have a project i worked on a while back which was just written against JDK 1.6 for an applet based application.
However now i could see how it could be useful in an android app that im interested in creating.
Do i now have to re-write all the code/tests again targeting the android sdk or can i just drop in my existing JAR file and only use android for the UI layer.
Its just android seems to make testing WAY harder than it needs to be, and i have alot of existing tests written and working, if it wasnt so hard to just write a quick unit test (standard Junit #Test style) i wouldnt mind porting, however i just dont get the whole instrumentation thing, as i dont need a UI at the moment...
Anyway so back to the point, can i use my existing JDK built code in an android app?
No!
Android uses the "Dalvik" VM from project harmony which uses a different set of bytecodes which are incompatable with the standard Java JVM bytecodes.
This was done both to optimise the VM for opreration on mobile platforms, and, probably more importantly to try and avoid Copyright and patent disputes with Sun and now Oracle.
More info here
However there is a tool called "dx" which can perform the conversion in the dev environment.
Okay, let me clear up your confusion.
Jars are converted to dex Dalvik bytecode during the compiling process thus you can use 3rd party jar libs.
However, in your case because its applet which has a different application lifecycle yes you might have to re-do it to get it to work in android.
As far as testing instrumentation is used on all java mobile development even JavaMe. It basically means that the Junit tests are run in the emulator or device but in android's case you are using android mock objects to test android specific things.

Categories

Resources