MCPcopy Index your code
hub / github.com/esmasui/AndroidJUnit4

github.com/esmasui/AndroidJUnit4 @android-junit4-parent-0.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release android-junit4-parent-0.5 ↗ · + Follow
2,112 symbols 5,069 edges 165 files 821 documented · 39%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Jenkins-CI Build Status

AndroidJUnit4

AndroidJUnit4 is a framework to running JUnit4 tests on Android devices with Eclipse/ADT or command line tools.

Supported API versions;

API level 3 (Cupcake) or later.

Build instruction;

1. Install Maven (http://maven.apache.org/)
2. Install android-sdks into local m2 repository using https://github.com/mosabua/maven-android-sdk-deployer    
3. Clone the repository

    $ git clone https://github.com/esmasui/AndroidJUnit4.git AndroidJUnit4-readonly

4. Build libraries

    $ cd AndroidJUnit4-readonly
    $ mvn eclipse:eclipse install

5. Import AndroidJunit4-readonly/android-junit4 as a Android library project or jar file to your Android test project.

You can also depend on the .jar through Maven:

<dependency>
    <groupId>com.uphyca</groupId>
    <artifactId>android-junit4</artifactId>
    <version>(insert latest version)</version>
</dependency>

If you need to run tests with maven-android-plugin, you need to set testSkip parameter to false in your configuration

<plugin>
    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
    <artifactId>android-maven-plugin</artifactId>
    <configuration>
        ...
        <test>
            <skip>false</skip>
        </test>
    </configuration>

</plugin>

or set android.test.skip environment to false

$ mvn clean install -Dandroid.test.skip=false

Continuous integration; http://jenkins.android-tec.org/job/JUnit4InstrumentationTestRunnerMaven/

Usage;

1. Set com.uphyca.testing.JUnit4InstrumentationTestRunner into instrumentation in your AndroidManifest.xml

    <instrumentation
        android:name="com.uphyca.testing.JUnit4InstrumentationTestRunner"
        android:targetPackage="your.test.package" />

2. Write your test classes that extends base test classes for Android dependent tests.

    The base test classses located in com.uphyca.testing package as same name of original android.test package's classes.
    For example; JUnit4 version of android.test.ActivityUnitTestCase is com.uphyca.testing.ActivityUnitTestCase.

Supported test classes are
    AndroidTestCase
    InstrumentationTestCase
    ActivityInstrumentationTestCase<T extends Activity>
    ActivityInstrumentationTestCase2<T extends Activity>
    ActivityTestCase, ActivityUnitTestCase<T extends Activity>
    ApplicationTestCase<T extends Application>
    LoaderTestCase
    ProviderTestCase<T extends ContentProvider>
    ProviderTestCase2<T extends ContentProvider>
    ServiceTestCase<T extends Service>
    SingleLaunchActivityTestCase<T extends Activity>
    SyncBaseInstrumentation

Example;

package com.uphyca.testing.test;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;

import org.junit.Before;
import org.junit.Test;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.uphyca.testing.ActivityUnitTestCase;
import com.uphyca.testing.AndroidJUnit4TestAdapter;
import com.uphyca.testing.test.HelloActivity.MyActivity;

public class HelloActivity extends ActivityUnitTestCase<MyActivity> {

    /**
     * For Eclipse with ADT
     */
    public static junit.framework.Test suite() {
        // Should use AndroidJUnit4TestAdapter for to running AndroidDependent
        // TestCases.
        return new AndroidJUnit4TestAdapter(HelloActivity.class);
    }

    public static class MyActivity extends Activity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            TextView view = new TextView(this);
            view.setText("Hello, activity.");
            view.setId(android.R.id.text1);
            setContentView(view);
        }
    }

    private Intent startIntent;

    public HelloActivity() {
        super(MyActivity.class);
    }

    @Override
    @Before
    public void setUp() throws Exception {
        super.setUp();
        startIntent = new Intent(Intent.ACTION_MAIN);
    }

    @Test
    public void assertPreconditions() {
        startActivity(startIntent, null, null);
        assertNotNull(getActivity());
    }

    @Test
    public void sayHello() {
        startActivity(startIntent, null, null);
        assertThat(((TextView) getActivity().findViewById(android.R.id.text1)).getText()
                                                                      .toString(), equalTo("Hello, activity."));
    }

}

License;

Copyright (C) 2012 uPhyca Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Extension points exported contracts — how you extend this code

TestCase (Interface)
{@hide} More complex interface for test cases. Just implementing Runnable is enough for many test cases. If you hav [45 …
android-junit4/src/main/java/android/test/TestCase.java
DelegateInterface (Interface)
(no doc) [3 implementers]
android-junit3-extension-support-v4-test/src/main/java/com/uphyca/testing/junit3/support/v4/test/DelegateFactoryTest.java
ActivityProxy (Interface)
(no doc) [2 implementers]
android-junit4-robolectric/src/main/java/com/uphyca/testing/proxy/android/app/ActivityProxy.java
Predicate (Interface)
A Predicate can determine a true or false value for any input of its parameterized type. For example, a {@code RegexPred [10 …
android-junit4/src/main/java/com/android/internal/util/Predicate.java
InvalidDelegateInterface (Interface)
(no doc) [3 implementers]
android-junit3-extension-support-v4-test/src/main/java/com/uphyca/testing/junit3/support/v4/test/DelegateFactoryTest.java
FragmentProxy (Interface)
(no doc) [1 implementers]
android-junit4-robolectric/src/main/java/com/uphyca/testing/proxy/android/support/v4/app/FragmentProxy.java
InstrumentationSupport (Interface)
(no doc) [18 implementers]
android-junit4/src/main/java/com/uphyca/testing/InstrumentationSupport.java
PerformanceResultsWriter (Interface)
Interface for reporting performance data. [2 implementers]
android-junit4/src/main/java/android/os/PerformanceCollector.java

Core symbols most depended-on inside this repo

tearDown
called by 49
android-junit4/src/main/java/android/test/TestCase.java
setUp
called by 48
android-junit4/src/main/java/android/test/TestCase.java
getInstrumentation
called by 33
android-junit4/src/main/java/com/uphyca/testing/InstrumentationSupport.java
getActivity
called by 30
android-junit4-robolectric/src/main/java/com/uphyca/testing/proxy/android/support/v4/app/FragmentProxy.java
getString
called by 27
android-junit4-robolectric/src/main/java/com/uphyca/testing/proxy/android/support/v4/app/FragmentProxy.java
startActivity
called by 24
android-junit4-robolectric/src/main/java/com/uphyca/testing/proxy/android/app/ActivityProxy.java
onCreate
called by 16
android-junit4-robolectric/src/main/java/com/uphyca/testing/proxy/android/app/ActivityProxy.java
getIntent
called by 14
android-junit4-robolectric/src/main/java/com/uphyca/testing/proxy/android/app/ActivityProxy.java

Shape

Method 1,897
Class 202
Interface 13

Languages

Java100%

Modules by API surface

android-junit4-robolectric/src/main/java/com/uphyca/testing/tester/android/app/DelegatingActivityProxy.java245 symbols
android-junit4-robolectric/src/main/java/com/uphyca/testing/proxy/android/app/ActivityProxy.java147 symbols
android-junit4-robolectric/src/main/java/com/uphyca/testing/tester/android/support/v4/app/DelegatingFragmentProxy.java63 symbols
android-junit4-robolectric/src/main/java/com/uphyca/testing/proxy/android/support/v4/app/FragmentProxy.java62 symbols
android-junit4-robolectric/src/main/java/com/uphyca/testing/tester/android/app/StubInstrumentation.java54 symbols
android-junit4/src/main/java/com/uphyca/testing/JUnit4InstrumentationTestRunner.java52 symbols
android-junit3-extension-support-v4/src/main/java/android/support/v4/app/FragmentManagerImplTrojanHorse.java49 symbols
android-junit4/src/main/java/android/test/TestRunner.java46 symbols
android-junit3-dbunit/src/main/java/com/uphyca/testing/junit3/dbunit/AndroidDBTestCase.java33 symbols
android-junit3-dbunit/src/main/java/com/uphyca/testing/junit3/dbunit/ProviderDBTestCase.java28 symbols
android-junit4-robolectric/src/main/java/com/uphyca/testing/support/v4/FragmentUnitTestCase.java26 symbols
android-junit4-robolectric/src/main/java/com/uphyca/testing/app/RobolectricInstrumentation.java24 symbols

For agents

$ claude mcp add AndroidJUnit4 \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact