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/
Related
Has anyone successfully able to run appium test from Android Studio ? I would appreciate if you could pass on to me a working sample of it.
I have been trying to get the setup running for over two weeks now. On trying to run test the build fails at preDexDebug step with below error
trouble processing "javax/xml/XMLConstants.class"
Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library. This is often due to inadvertently including a core library file in your application's project, when using an IDE (such as Eclipse). If you are sure you're not intentionally defining a core class, then this is the most likely explanation of what's going on.
However, you might actually be trying to define a class in a core namespace, the source of which you may have taken, for example from a non-Android virtual machine project. This will most assuredly not work. At a minimum, it jeopardizes the compatibility of your app with future versions of the platform.
It is also often of questionable legality. If you really intend to build a core library -- which is only appropriate as part of creating a full virtual machine distribution, as opposed to compiling an application -- then use the \"--core-library\" option to suppress this error message.
.......... and the error goes on.
I tried using the --core-library option. however the error still persists.
I am making use of maven to gather the dependencies for appium.
compile 'io.appium:java-client:3.2.0'
My primary question: is appium and its dependencies compatible to run with Android Studio? Because it runs pretty smooth on Eclipse
Commenting io.appium dependency solve the mentioned build error, but I have to comment my tests.
After exhausting my own knowledge, I read a couple of posts on stackoverflow and other internet resources around my problem, but there is no concrete solution. It is more of a hit-and-try mechanism saying "this might work". I tried them, but with no success.
Hence, I would like to know
Firstly, if appium and its dependencies work very well with Android Studio
A zip of working solution (if possible)
Any help is much appreciated.
Steps for Appium Setup in Android Studio:
Download - Android Studio Appium Java Client Selenium Client Library Appium Server Install Java
Install Android Studio please follow the steps given in the link to
Install android studio step by step on windows machine click here After installation of android studio ,open android studio and create a new project - How to create android project?
Add the downloaded Appium jars into your project - click on project -> click on app->copy all the jars in lib. Select the copied jars except Selenium, Java client and Junit Jar ,then right click on it and click on "Add as Library".
Click on build.gradle in app you will see all the libs added like below screenshot add junit:4.12.Sync the project or Re-build the project. It should show "Build Successful Message"
Now you are ready to write your first test case - right click on the package and click on "Create Java Class". Copy given test case sample.
Running the Test case-
Click on build variant Select Unit Testing Start the appium server with Specific port "4444"click here Connect device with USB debugging on or start an emulator. Right click on the test class and click on "Run"
This steps for taken from this post and video.
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
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.