To run my JUnit tests on my Android application, do I have to create a different project or I can include them in my project? If yes, how?
This link from android developers provides full explanations:
http://developer.android.com/tools/testing/testing_android.html
Tests should be included in the same project nearby src folder
JUnit Test in Android is same as it was in Java.
You can also create Android Test Project
for more information please visit: http://developer.android.com/tools/testing/testing_android.html
and
http://developer.android.com/tools/testing/testing_eclipse.html
Related
I want to write a few unit tests in IntelliJ to test out an app I have found on F-Droid called AAT. I want to use the source code available on F-Droid to build the application in IntelliJ/run it on an emulator/test the application using a few unit tests that I've written in IntelliJ.
However, I'm confused about how I would upload the source code for an app in IntelliJ. How would I use the source code for an app to "build" it in IntelliJ? Also, how would I have to structure my project files to be able to run my unit tests on the application once its been built?
Please let me know if I'm not being clear enough, thank you.
I was able to do this by creating a new project from version control (Github) and specifying the url for the project repository on Github!
I'd like to add my AndroidTests to an existing project and run it from eclipse. I do not want to have a separate Eclipse project for the tests.
Is this possible?
When I try, Eclipse complains that uses-library instrumentation is required, which effectively means that an Android project cannot run its instrumentation tests if they are within the same project.
Using gradle, I can place my Android test code within the same project as the source production code, but I cannot do the same with Eclipse.
This leads to a disconnect where there ends up being 2x as many Android projects just to run in Eclipse, when gradle can handle single projects just fine.
Are there any workarounds?
Is this possible?
If the project creates an Android library project, then yes. If the project creates an Android application, then no. An Eclipse project basically creates one APK output, which can either be a test project (perhaps incorporating code from a library) or an application, but not both.
I have run into some issues while working on Android JUnit Test, the details of which are given below.
I have an Android application (which is to be tested) and a corresponding JUnit Test project (which tests the application). Also, I have another project, which contains some native library which I intend to use in my Test project.
I have tried to use the other project as a library under eclipse but when running the JUnit test, an error comes up stating “findLibrary returned null”.
There is a workaround for this by putting the native library in the application to be tested and then using it. But I don’t want to put the testing library in the application. Is there any solution for this?
I would like to test my library in an android application, but I would like to avoid compiling and moving around .jar files.
In Xcode for iOs development, it's possible to add your library project in your workspace inside your other project (a test app) and when you run your test app, it builds the library and links everything up correctly.
Can I do this for Android development in Eclipse? How can I do this?
I tried to add a library but it seemed very manual which isn't ideal on time.
The important thing here is that I do have Android references and dependancies, so i can't just unit test the library by itself. I am also creating an SQLite database which I would like to inspect during development.
I guess you are asking about Android Library projects, otherwise you can just test your library using JUnit.
In such case, the post android: testing library projects gives you a step by step guide on how to proceed to test the Android Library project in a stand-alone fashion. Think it can also be tested through the tests belonging to the Android project that uses the library.
You can test your library code using RoboElectric that allows you to test without the need of deploying an android emulator.
Or you can set your library project as an Android library project and put the test in the first project. link
In latest android SDK tools you do not need to add jar in build path, they will be added automatically.
you can put you jar file in libs folder of your project, But it will defiantly be compile before running.
Have someone got any tutorials for how to do testing on Android in Intellij? I am looking for resources similar to what you find for Eclipse with the ability to create a test project for my android project.
You can find some help in the IDEA forum thread.
Tests for Android application should be located in a separate module with its
own AndroidManifest.xml file. To find out how to create tests for your
Android application, you can use samples in Android SDK (i.e. "Snake"
sample).
Create IDEA project from existing sources. 2 modules with
Android facets will be created automatically: base module and "tests". Then
add dependency between these module and compile. If compilation is
successful, open some test class (i.e. "SkeletonAppTest" in "Snake" sample)
in editor and select Run->SkeletonAppTest (with Android icon) in the popup
menu: tests will run on emulator or device. You can create Android
Tests run configuration to run tests in different scopes.
Unfortunately, IDEA 9 doesn't have an option to create test module for some
base Android module. You can create it using SDK command-line tool.
Here's the general Android/Eclipse info:
Android testing overview:
http://developer.android.com/guide/topics/testing/index.html
Testing practicalities for Eclipse and command line:
http://developer.android.com/guide/developing/testing/index.html
Tutorial:
http://developer.android.com/resources/tutorials/testing/helloandroid_test.html
and to create a test project in IntelliJ:
http://blogs.jetbrains.com/idea/2010/09/android-unit-testing-support/