Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8369701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:43:03+00:00 2026-06-09T13:43:03+00:00

as the documentation of Android says, Note that the Android testing API supports JUnit

  • 0

as the documentation of Android says, “Note that the Android testing API supports JUnit 3 code style, but not JUnit 4.” (Testing Fundamentals). It should be clear that JUnit 4 cannot be used out of the box with Android.

But why is this the case? Is it because the tests are executed within the DVM (in that the Android Runtime only has support for JUnit 3)? On a JVM one on its own could choose the JUnit runtime that should be used. Isn’t this possible within the DVM?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:43:05+00:00Added an answer on June 9, 2026 at 1:43 pm

    Update 2015/10

    It is now possible via the AndroidJUnitRunner, which is part of the Android Testing Support Library. In short, you need to do the following in a Gradle-based project:

    1. Add the dependencies:

      dependencies {
          compile 'com.android.support:support-annotations:22.2.0'
          androidTestCompile 'com.android.support.test:runner:0.4.1'
      }
      
    2. Specify the testInstrumentationRunner:

      android {
          defaultConfig {
              testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
          }
      }
      
    3. Annotate your test class with @RunWith(AndroidJUnit4.class).

    4. Write your tests in normal JUnit4 style.

    Also see the Espresso setup instructions. Note that you don’t need Espresso itself for plain JUnit4 tests.

    Why it’s needed

    There are very little information I could find on the internet on this topic. The best I found was the info on InstrumentationTestRunner.

    There are nothing preventing JUnit4 tests from running on an Android device just like any other Java code. However, the Android test framework does some additional work:

    1. It sends test results back to your development machine over ADB.
    2. It does instrumentation (I’m not sure what exactly this involves).

    The above is performed by some extensions specifically for JUnit3.

    This JUnit3-specific code seems to be part of the InstrumentationTestRunner which forms part of the core Android system. However, as is evident with AndroidJUnitRunner, it is possible to use a custom test runner that supports JUnit4 or other frameworks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Android documentation says that best practices are to make two drawable directories -
I have gone through SIP Manager Documentation , it says - Not all Android-powered
Android documentation says that AsyncTask postExecute() is called on the UI thread. I was
The Android documentation says the following about IntentService: [IntentService] creates a work queue that
The documentation at http://code.google.com/android/reference/android/widget/AbsoluteLayout.html says: onLayout(boolean changed, int l, int t, int r, int
The Android Documentation says that there is two sizes for a view, the measured
Android SDK documentation says that startManagingCursor() method is depracated: This method is deprecated. Use
On android, the GLSurfaceView documentation says this: A GLSurfaceView must be notified when the
I want to have a full documentation for android ndk. or a url that
I have an android app that wants to initiate an email. The following code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.