Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test an Android Library Project

Tags:

android

junit

apk

I am writing an Android Library Project basing on Android Bitmap class (call it AndroindLib) which contains only utility class (no activity). I tried to test it using Android JUnit, but it keeps complaining that can't find the AnroidLib.apk

What's the right way to Unit test Android Library Project?

like image 396
Lily Avatar asked Aug 30 '10 19:08

Lily


People also ask

How can I test my Android app?

Before starting your application, Android studio will display following window to select an option where you want to run your Android application. Select your mobile device as an option and then check your mobile device which will display application screen.

How do I run a test file on Android?

Right click on a test class name in the editor (or a filename in the project explorer) to run all tests in a single class. The default keyboard shortcut for this is Ctrl+Shift+F10 on Linux.

How do I test an APK file?

Navigate to the App Live dashboard. Upload the APK file and choose the desired Android device to test on. Start testing.

How do Android libraries work?

An Android library is structurally the same as an Android app module. It can include everything needed to build an app, including source code, resource files, and an Android manifest.


1 Answers

Quoting the documentation:

"There are two recommended ways of setting up testing on code and resources in a library project:

  • You can set up a test project that instruments an application project that depends on the library project. You can then add tests to the project for library-specific features.

  • You can set up a standard application project that depends on the library and put the instrumentation in that project. This lets you create a self-contained project that contains both the tests/instrumentations and the code to test."

like image 61
CommonsWare Avatar answered Oct 20 '22 08:10

CommonsWare