JUnit 和 Android JUnit

Android JUnit测试说明和实例演示 什么是 JUnit ? JUnit是采用测试驱动开发的方式,也就是说在开发前先写好测试代码,主要用来说明被测试的代码会被如何使用,错误处理等;然后开始写代码,并在测试代码中逐步测试这些代码,直到最后在测试代码中完全通过。 现简要说JUnit的4大功能 管理测试用例。修改了哪些代码,这些代码的修改会对哪些部分有影响,通过JUnit将这次的修改做个完整测试。这也就JUnit中所谓的T 阅读详情

因为最近学习TDD,所以JUnit是必须要会的,在这里整理一下,发出来。

什么是TDD:

Test Driven Development--测试驱动开发
别人说的一些话:
TDD就是把你的需求用测试给描述出来。
没有Mock的单元测试就很可能不是单元测试,也许是集成测试,也许是功能测试,总之不是TDD中所需要的那种能够驱动你开发的测试。
和传统开发方法里的详细设计不同,写一个单元测试,就写一段代码让它通过。这样你就不需要在实现的时候,再去读文档,再去回忆当时是怎么想的,能提高效率;更重要的是,这个“文档”是能反复运行的,可以保证和实现的一致性。


Robert C. Martin:
1.除非这能让失败的单元测试通过,否则不允许去编写任何的产品代码。
2.只允许编写刚好能够导致失败的单元测试。 (编译失败也属于一种失败)
3.只允许编写刚好能够导致一个失败的单元测试通过的产品代码。
对于任何功能,一定要从编写它的单元测试开始;但是到了原则2,你就不能再为那个单元测试写更多内容。只要一出现该单元测试代码编译失败,或是断言失败,你就必须停下来开始编写产品代码;但是到了原则3,你就只能编写产品代码,直到让测试编译成功或通过断言为准。

单元测试三条规则:
每个单元测试都必须独立于其他单元测试而运行。
必须以单元测试为单位来检测和报告错误。
必须易于定于要运行哪些单元测试。

当你需要编写更多的test case的时候,你可以创建更多的TestCase对象。当你需要一次执行多个TestCase对象的时候,你可以创建另一个叫做TestSuite的对象。为了执行TestSuite,你需要使用TestRunner。

TestCase + TestSuite + BaseTestRunner = TestResult
Test runner:
JUnit发布包中包含了3个TestRunner类:一个用户文本控制台,一个用户Swing,甚至还有一个AWT。
并不存在TestRunner接口,这和JUnit框架中的其它元素不同。相反,JUnit附带的几个test runner都是继承自BaseTestRunner。如果你不管什么理由需要编写你自己的test runner,你也可以继承这个类。例如:Cactus框架就继承了BaseTestRunner来创建一个ServletTestRunner,可以从浏览器中运行JUnit测试。

用TestSuite来组合测试:
若想要运行多个test case又会如何呢?如果想在多个test case中选一部分又怎样呢?应当如何来为test case分组呢?
看来,在TestCase和TestRunner之间,你还需要某种容器,用来把几个测试归在一起,并且把他们作为一个集合一起运行,但是,在使得多个test case运行得以简化的同时,你也不希望让运行单个test case变得复杂化。
JUnit对这个难题的回答是TestSuite。TestSuite被设计成可以运行一个或多个test case,test runner负责启动TestSuite,而要运行哪些test case则由TestSuite来决定。
若你没有提供自己的TestSuite,test runner会自动创建一个。
缺省的TestSuite会扫描你的测试类,找出所有以test开头的方法。缺省的TestSuite在内部为每个testXXX方法都创建一个TestSuite的实例,要调用的方法的名字会传递给TestCase的构造函数,这样每个实例就有一个独一无二的标识。
用TestResult来收集参数:
TestResult负责收集TestCase的执行结果。如果所有的测试都总是可以顺利的完成,那么为什么还要运行他们呢?所以,TestResult储存了所有测试的详细情况,是通过还是失败。
TestRunner使用TestResult来报告测试结果。如果TestResult集合中没有TestFailure对象,那么代码就是干净的,进度条就的绿色的;否则TestRunner就会报失败,并输出失败测试的数目和它们的stack trace。
你只需要知道他的存在就OK了。
用TestListener来观察结果:
JUnit框架提供了TestListener接口,以帮组对象访问TestResult并创建有用的报告。TestRunner实现了 TestListener,很多特定的JUnit扩展和实现了TestListener。可以有任意数量的TestLintener向JUnit框架注册,这些TestListener可以根据TestResult提供的信息做它们需要做的任何事情。
用TestCase来工作:
概括地说,JUnit的工作过程就是由TestRunner来运行包含一个或者多个TestCase(或者其他TestSuite)的TestSuite。但是在常规的工作中,你通常只和TestCase打交道。

android对我们的JUnit进行了扩展:

runner:

AndroidTestRunner  extends BaseTestRunner :

demo:

package cn.partner4java;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

/**
* 主要的入口,负责显示button,点击button后触发测试事件,显示测试信息
* @author partner4java
*
*/
public class MainActivity extends Activity {
    private static final String TAG = "JUnit";
    private Thread mRuner ;
  
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
      
        ((Button) this.findViewById(R.id.start_junit)).setOnClickListener(
                new View.OnClickListener(){
                    public void onClick(View v) {
                        startJUnit();
                    }
                }
        );
    }
    /**
     * on click start all JUnit
     */
    protected void startJUnit() {
        if(mRuner == null){
            Log.d(TAG, "startJUnit");
            mRuner = new Thread(new JUnitRunner(this));
            mRuner.start();
        }
    }
}


上面:通过触摸点击事件,启动一个新线程

package cn.partner4java;

import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestListener;
import android.app.Activity;
import android.test.AndroidTestRunner;
import android.util.Log;

/**
* 首先我是一个runner,然后我实现了TestListener,我可以监听JUnit处理错误
* @author partner4java
*
*/
public class JUnitRunner implements Runnable,TestListener {
    private static final String TAG = "JUnit";
    private Activity mActivity;
  
    private int mCount;
    private int mErrorCount;
    private int mFailureCount;
  
    private AlterShowText mAlterShowText;
  
    public JUnitRunner(Activity activity) {
        mActivity = activity;
    }

    public void run() {
        Log.d(TAG, "JUnitRunner run");
        mCount = 0;
        mErrorCount = 0;
        mFailureCount = 0;
        AndroidTestRunner androidTestRunner = new AndroidTestRunner();
        androidTestRunner.setContext(mActivity);
        androidTestRunner.addTestListener(this);
        androidTestRunner.setTest(new AllSuite());
        androidTestRunner.runTest();
        Log.d(TAG, "run my androidTestRunner");
    }

    public void addError(Test test, Throwable t) {
        ++mErrorCount;
        Log.d(TAG, "addError className:" + test.getClass().getName());
        Log.d(TAG, t.getMessage(), t);
        mAlterShowText = new AlterShowText(mActivity,"error:" + test.getClass().getName(),mCount,mErrorCount,mFailureCount);
        mActivity.runOnUiThread(mAlterShowText);
    }

    public void addFailure(Test test, AssertionFailedError t) {
        Log.d(TAG, "addFailure className:" + test.getClass().getName());
        Log.d(TAG, t.getMessage(), t);
        ++mFailureCount;
        mAlterShowText = new AlterShowText(mActivity,"failure:" + test.getClass().getName(),mCount,mErrorCount,mFailureCount);
        mActivity.runOnUiThread(mAlterShowText);
    }

    public void endTest(Test test) {
        Log.d(TAG, "endTest className:" + test.getClass().getName());
        mAlterShowText = new AlterShowText(mActivity,"end:" + test.getClass().getName(),mCount,mErrorCount,mFailureCount);
        mActivity.runOnUiThread(mAlterShowText);
    }

    public void startTest(Test test) {
        Log.d(TAG, "startTest className:" + test.getClass().getName());
        ++mCount;
        mAlterShowText = new AlterShowText(mActivity,"start:" + test.getClass().getName(),mCount,mErrorCount,mFailureCount);
        mActivity.runOnUiThread(mAlterShowText);
    }

}

我们线程里面run了一个runner:

AndroidTestRunner androidTestRunner = new AndroidTestRunner();
        androidTestRunner.setContext(mActivity);
        androidTestRunner.addTestListener(this);
        androidTestRunner.setTest(new AllSuite());
        androidTestRunner.runTest();

这个runner注册了test suite 和 listener,这个listner会监视四个事件:addError/addFailure/endTest/startTest,四个事件。也就是说,我们runner去启动了一个test suite,然后注册了一个监听,去监听每次执行test不同的场景。

package cn.partner4java;

import cn.partner4java.test.MyTest;
import junit.framework.TestSuite;

/**
* 测试集合
* @author partner4java
*
*/
public class AllSuite extends TestSuite {
    /**
     * 按照以前的思想,我这里原来添加的是 suite 方法,但是不对。。
     */
    public AllSuite(){
        addTestSuite(MyTest.class);
    }
}

package cn.partner4java;

import android.app.Activity;
import android.util.Log;
import android.widget.TextView;

/**
* 我是一个线程,如果想改变界面显示,ok,把我new 出来,然后运行近界面显示线程
* @author partner4java
*
*/
public class AlterShowText implements Runnable {
    private static final String TAG = "JUnit";
    private String mName;
    private int mCount;
    private int mErrorCount;
    private int mFailureCount;
    private Activity mActivity;
    private TextView mCurrentJUnit;
    private TextView mCurrentCount;
    private TextView mCurrentErrorCount;
    private TextView mCurrentFailureCount;
  
    public AlterShowText(Activity activity,String name, int count, int errorCount, int failureCount) {
        Log.d(TAG, "AlterShowText public mName:" + name);
        mActivity = activity;
        mCurrentJUnit = (TextView) mActivity.findViewById(R.id.current_JUnit);
        mCurrentCount = (TextView) mActivity.findViewById(R.id.current_count);
        mCurrentErrorCount = (TextView) mActivity.findViewById(R.id.current_error_count);
        mCurrentFailureCount = (TextView) mActivity.findViewById(R.id.current_failure_count);
        mName = name;
        mCount = count;
        mErrorCount = errorCount;
        mFailureCount = failureCount;
    }

    public void run() {
        if(mName != null){
            Log.d(TAG, "AlterShowText run");
            mCurrentJUnit.setText(mName);
            mCurrentCount.setText(String.valueOf(mCount));
            mCurrentErrorCount.setText(String.valueOf(mErrorCount));
            mCurrentFailureCount.setText(String.valueOf(mFailureCount));
        }  
    }
  
}
事件触发后会执行这个类去改变界面的显示,需要注意的是: mActivity.runOnUiThread(mAlterShowText);监听里面的界面修改是回到UI线程的,因为只有在UI线程才可以修改界面的显示。

package cn.partner4java.test;

import android.util.Log;
import junit.framework.TestCase;

/**
* 单元测试
* @author partner4java
*
*/
public class MyTest extends TestCase {
  
    private static final String TAG = "JUnit";

    public void testAdd(){
        Log.d(TAG, "MyTest testAdd");
    }
}

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    />
   
    <Button
        android:id="@+id/start_junit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="StartJUnit"/>
    <TextView
        android:id="@+id/current_JUnit"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text=""/>
    <TextView
        android:id="@+id/current_count"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text=""/>
       
    <TextView
        android:id="@+id/current_error_count"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text=""/>
    <TextView
        android:id="@+id/current_failure_count"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text=""/>                       
   
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="cn.partner4java"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".MainActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <uses-library android:name="android.test.runner"/>
    </application>
</manifest>


InstrumentationTestRunner extends Instrumentation
implements TestSuiteProvider :

这个并没有像我们想象的那样去继承 BaseTestRunner ,那么好让我们看看Instrumentation

是做什么的呢?

Base class for implementing application instrumentation code. When running with instrumentation turned on, this class will be instantiated for you before any of the application code, allowing you to monitor all of the interaction the system has with the application. An Instrumentation implementation is described to the system through an AndroidManifest.xml's <instrumentation> tag.

原来是一个自动监听器,估计作用和我们上面的lintener一样,只是这里为什么没用listener估计这里不是简简单单的对虚拟机监听,是android环境的特殊监听,所以就自己搞了个


在AndroidMainfest文件添加:<instrumentation android:name="android.test.InstrumentationTestRunner"
                     android:targetPackage="cn.partner4java"
                     android:label="Tests for Api Demos."/>

name就算runner,targetPackage是我们要测试的包名

常用的test case:

          * ActivityInstrumentationTestCase2
          
* ActivityUnitTestCase
          
* AndroidTestCase
          
* ApplicationTestCase
          
* InstrumentationTestCase
          
* ProviderTestCase
          
* ServiceTestCase
          
* SingleLaunchActivityTestCase

当然这几个test case各具特色,应用场景略有不同。

runner如何运行test case:

  1. Run the instrumentation using "adb shell am instrument -w", with no optional arguments, to run all tests (except performance tests).
  2. Run the instrumentation using "adb shell am instrument -w", with the argument '-e func true' to run all functional tests. These are tests that derive from InstrumentationTestCase .
  3. Run the instrumentation using "adb shell am instrument -w", with the argument '-e unit true' to run all unit tests. These are tests that do not derive from InstrumentationTestCase (and are not performance tests).
  4. Run the instrumentation using "adb shell am instrument -w", with the argument '-e class' set to run an individual TestCase .

Running all tests: adb shell am instrument -w com.android.foo/android.test.InstrumentationTestRunner

Running all small tests: adb shell am instrument -w -e size small com.android.foo/android.test.InstrumentationTestRunner

Running all medium tests: adb shell am instrument -w -e size medium com.android.foo/android.test.InstrumentationTestRunner

Running all large tests: adb shell am instrument -w -e size large com.android.foo/android.test.InstrumentationTestRunner

Filter test run to tests with given annotation: adb shell am instrument -w -e annotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner

If used with other options, the resulting test run will contain the union of the two options. e.g. "-e size large -e annotation com.android.foo.MyAnnotation" will run only tests with both the LargeTest and "com.android.foo.MyAnnotation" annotations.

Filter test run to tests without given annotation: adb shell am instrument -w -e notAnnotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner

Running a single testcase: adb shell am instrument -w -e class com.android.foo.FooTest com.android.foo/android.test.InstrumentationTestRunner

Running a single test: adb shell am instrument -w -e class com.android.foo.FooTest#testFoo com.android.foo/android.test.InstrumentationTestRunner

Running multiple tests: adb shell am instrument -w -e class com.android.foo.FooTest,com.android.foo.TooTest com.android.foo/android.test.InstrumentationTestRunner

Running all tests in a java package: adb shell am instrument -w -e package com.android.foo.subpkg com.android.foo/android.test.InstrumentationTestRunner

Including performance tests: adb shell am instrument -w -e perf true com.android.foo/android.test.InstrumentationTestRunner

To debug your tests, set a break point in your code and pass: -e debug true

To run in 'log only' mode -e log true This option will load and iterate through all test classes and methods, but will bypass actual test execution. Useful for quickly obtaining info on the tests to be executed by an instrumentation command.

To generate EMMA code coverage: -e coverage true Note: this requires an emma instrumented build. By default, the code coverage results file will be saved in a /data//coverage.ec file, unless overridden by coverageFile flag (see below)

To specify EMMA code coverage results file path: -e coverageFile /sdcard/myFile.ec
in addition to the other arguments.

还有,当我们需要写测试代码时,可以格外的创建测试工程,只要创建的时候选折对那个工程进行测试就OK了

补一个例子:8里面多了这个demo,感觉对 ActivityInstrumentationTestCase2用的比较经典了

首先项目里就这么一个activity:

/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * 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.
 */

package com.android.example.spinner;

import com.android.example.spinner.R;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemSelectedListener;

/**
 * Displays an Android spinner widget backed by data in an array. The
 * array is loaded from the strings.xml resources file.
 */
public class SpinnerActivity extends Activity {

    /**
     * Fields to contain the current position and display contents of the spinner
     */
    protected int mPos;
    protected String mSelection;

    /**
     * ArrayAdapter connects the spinner widget to array-based data.
     */
    protected ArrayAdapter<CharSequence> mAdapter;

    /**
     *  The initial position of the spinner when it is first installed.
     */
    public static final int DEFAULT_POSITION = 2;

    /**
     * The name of a properties file that stores the position and
     * selection when the activity is not loaded.
     */
    public static final String PREFERENCES_FILE = "SpinnerPrefs";

    /**
     * These values are used to read and write the properties file.
     * PROPERTY_DELIMITER delimits the key and value in a Java properties file.
     * The "marker" strings are used to write the properties into the file
     */
    public static final String PROPERTY_DELIMITER = "=";

    /**
     * The key or label for "position" in the preferences file
     */
    public static final String POSITION_KEY = "Position";

    /**
     * The key or label for "selection" in the preferences file
     */
    public static final String SELECTION_KEY = "Selection";

    public static final String POSITION_MARKER =
            POSITION_KEY + PROPERTY_DELIMITER;

    public static final String SELECTION_MARKER =
            SELECTION_KEY + PROPERTY_DELIMITER;

    /**
     * Initializes the application and the activity.
     * 1) Sets the view
     * 2) Reads the spinner's backing data from the string resources file
     * 3) Instantiates a callback listener for handling selection from the
     *    spinner
     * Notice that this method includes code that can be uncommented to force
     * tests to fail.
     *
     * This method overrides the default onCreate() method for an Activity.
     *
     * @see android.app.Activity#onCreate(android.os.Bundle)
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {

        /**
         * derived classes that use onCreate() overrides must always call the super constructor
         */
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        Spinner spinner = (Spinner) findViewById(R.id.Spinner01);

        /*
         * Create a backing mLocalAdapter for the Spinner from a list of the
         * planets. The list is defined by XML in the strings.xml file.
         */

        this.mAdapter = ArrayAdapter.createFromResource(this, R.array.Planets,
                android.R.layout.simple_spinner_dropdown_item);

        /*
         * Attach the mLocalAdapter to the spinner.
         */

        spinner.setAdapter(this.mAdapter);

        /*
         * Create a listener that is triggered when Android detects the
         * user has selected an item in the Spinner.
         */

        OnItemSelectedListener spinnerListener = new myOnItemSelectedListener(this,this.mAdapter);

        /*
         * Attach the listener to the Spinner.
         */

        spinner.setOnItemSelectedListener(spinnerListener);


        /*
         * To demonstrate a failure in the preConditions test,
         * uncomment the following line.
         * The test will fail because the selection listener for the
         * Spinner is not set.
         */
         // spinner.setOnItemSelectedListener(null);

    }


    /**
     *  A callback listener that implements the
     *  {@link android.widget.AdapterView.OnItemSelectedListener} interface
     *  For views based on adapters, this interface defines the methods available
     *  when the user selects an item from the View.
     *
     */
    public class myOnItemSelectedListener implements OnItemSelectedListener {

        /*
         * provide local instances of the mLocalAdapter and the mLocalContext
         */

        ArrayAdapter<CharSequence> mLocalAdapter;
        Activity mLocalContext;

        /**
         *  Constructor
         *  @param c - The activity that displays the Spinner.
         *  @param ad - The Adapter view that
         *    controls the Spinner.
         *  Instantiate a new listener object.
         */
        public myOnItemSelectedListener(Activity c, ArrayAdapter<CharSequence> ad) {

          this.mLocalContext = c;
          this.mLocalAdapter = ad;

        }

        /**
         * When the user selects an item in the spinner, this method is invoked by the callback
         * chain. Android calls the item selected listener for the spinner, which invokes the
         * onItemSelected method.
         *
         * @see android.widget.AdapterView.OnItemSelectedListener#onItemSelected(
         *  android.widget.AdapterView, android.view.View, int, long)
         * @param parent - the AdapterView for this listener
         * @param v - the View for this listener
         * @param pos - the 0-based position of the selection in the mLocalAdapter
         * @param row - the 0-based row number of the selection in the View
         */
        public void onItemSelected(AdapterView<?> parent, View v, int pos, long row) {

            SpinnerActivity.this.mPos = pos;
            SpinnerActivity.this.mSelection = parent.getItemAtPosition(pos).toString();
            /*
             * Set the value of the text field in the UI
             */
            TextView resultText = (TextView)findViewById(R.id.SpinnerResult);
            resultText.setText(SpinnerActivity.this.mSelection);
        }

        /**
         * The definition of OnItemSelectedListener requires an override
         * of onNothingSelected(), even though this implementation does not use it.
         * @param parent - The View for this Listener
         */
        public void onNothingSelected(AdapterView<?> parent) {

            // do nothing

        }
    }

    /**
     * Restores the current state of the spinner (which item is selected, and the value
     * of that item).
     * Since onResume() is always called when an Activity is starting, even if it is re-displaying
     * after being hidden, it is the best place to restore state.
     *
     * Attempts to read the state from a preferences file. If this read fails,
     * assume it was just installed, so do an initialization. Regardless, change the
     * state of the spinner to be the previous position.
     *
     * @see android.app.Activity#onResume()
     */
    @Override
    public void onResume() {

        /*
         * an override to onResume() must call the super constructor first.
         */

        super.onResume();

        /*
         * Try to read the preferences file. If not found, set the state to the desired initial
         * values.
         */

        if (!readInstanceState(this)) setInitialState();

        /*
         * Set the spinner to the current state.
         */

        Spinner restoreSpinner = (Spinner)findViewById(R.id.Spinner01);
        restoreSpinner.setSelection(getSpinnerPosition());

    }

    /**
     * Store the current state of the spinner (which item is selected, and the value of that item).
     * Since onPause() is always called when an Activity is about to be hidden, even if it is about
     * to be destroyed, it is the best place to save state.
     *
     * Attempt to write the state to the preferences file. If this fails, notify the user.
     *
     * @see android.app.Activity#onPause()
     */
    @Override
    public void onPause() {

        /*
         * an override to onPause() must call the super constructor first.
         */

        super.onPause();

        /*
         * Save the state to the preferences file. If it fails, display a Toast, noting the failure.
         */

        if (!writeInstanceState(this)) {
             Toast.makeText(this,
                     "Failed to write state!", Toast.LENGTH_LONG).show();
          }
    }

    /**
     * Sets the initial state of the spinner when the application is first run.
     */
    public void setInitialState() {

        this.mPos = DEFAULT_POSITION;

    }

    /**
     * Read the previous state of the spinner from the preferences file
     * @param c - The Activity's Context
     */
    public boolean readInstanceState(Context c) {

        /*
         * The preferences are stored in a SharedPreferences file. The abstract implementation of
         * SharedPreferences is a "file" containing a hashmap. All instances of an application
         * share the same instance of this file, which means that all instances of an application
         * share the same preference settings.
         */

        /*
         * Get the SharedPreferences object for this application
         */

        SharedPreferences p = c.getSharedPreferences(PREFERENCES_FILE, MODE_WORLD_READABLE);
        /*
         * Get the position and value of the spinner from the file, or a default value if the
         * key-value pair does not exist.
         */
        this.mPos = p.getInt(POSITION_KEY, SpinnerActivity.DEFAULT_POSITION);
        this.mSelection = p.getString(SELECTION_KEY, "");

        /*
         * SharedPreferences doesn't fail if the code tries to get a non-existent key. The
         * most straightforward way to indicate success is to return the results of a test that
         * SharedPreferences contained the position key.
         */

          return (p.contains(POSITION_KEY));

        }

    /**
     * Write the application's current state to a properties repository.
     * @param c - The Activity's Context
     *
     */
    public boolean writeInstanceState(Context c) {

        /*
         * Get the SharedPreferences object for this application
         */

        SharedPreferences p =
                c.getSharedPreferences(SpinnerActivity.PREFERENCES_FILE, MODE_WORLD_READABLE);

        /*
         * Get the editor for this object. The editor interface abstracts the implementation of
         * updating the SharedPreferences object.
         */

        SharedPreferences.Editor e = p.edit();

        /*
         * Write the keys and values to the Editor
         */

        e.putInt(POSITION_KEY, this.mPos);
        e.putString(SELECTION_KEY, this.mSelection);

        /*
         * Commit the changes. Return the result of the commit. The commit fails if Android
         * failed to commit the changes to persistent storage.
         */

        return (e.commit());

    }

    public int getSpinnerPosition() {
        return this.mPos;
    }

    public void setSpinnerPosition(int pos) {
        this.mPos = pos;
    }

    public String getSpinnerSelection() {
        return this.mSelection;
    }

    public void setSpinnerSelection(String selection) {
        this.mSelection = selection;
    }
}

另创建测试工程:

/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * 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.
 */

package com.android.example.spinner.test;

import com.android.example.spinner.SpinnerActivity;

import android.app.Instrumentation;
import android.test.ActivityInstrumentationTestCase2;
import android.test.UiThreadTest;
import android.view.KeyEvent;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;

/*
 * Tests the example application Spinner. Uses the instrumentation test class
 * ActivityInstrumentationTestCase2 as its base class. The tests include
 *   - test initial conditions
 *   - test the UI
 *   - state management - preserving state after the app is shut down and restarted, preserving
 *     state after the app is hidden (paused) and re-displayed (resumed)
 *
 * Demonstrates the use of JUnit setUp() and assert() methods.
 */
public class SpinnerActivityTest extends ActivityInstrumentationTestCase2<SpinnerActivity> {

    // Number of items in the spinner's backing mLocalAdapter

    public static final int ADAPTER_COUNT = 9;

    // The location of Saturn in the backing mLocalAdapter array (0-based)

    public static final int TEST_POSITION = 5;

    // Set the initial position of the spinner to zero

    public static final int INITIAL_POSITION = 0;

    // The initial position corresponds to Mercury

    public static final String INITIAL_SELECTION = "Mercury";

    // Test values of position and selection for the testStateDestroy test

    public static final int TEST_STATE_DESTROY_POSITION = 2;
    public static final String TEST_STATE_DESTROY_SELECTION = "Earth";

    // Test values of position and selection for the testStatePause test

    public static final int TEST_STATE_PAUSE_POSITION = 4;
    public static final String TEST_STATE_PAUSE_SELECTION = "Jupiter";

    // The Application object for the application under test

    private SpinnerActivity mActivity;

    // String displayed in the spinner in the app under test

    private String mSelection;

    // The currently selected position in the spinner in the app under test

    private int mPos;

    /*
     *  The Spinner object in the app under test. Used with instrumentation to control the
     *  app under test.
     */

    private Spinner mSpinner;

    /*
     * The data backing the Spinner in the app under test.
     */

    private SpinnerAdapter mPlanetData;

    /*
     * Constructor for the test class. Required by Android test classes. The constructor
     * must call the super constructor, providing the Android package name of the app under test
     * and the Java class name of the activity in that application that handles the MAIN intent.
     */
    public SpinnerActivityTest() {

        super("com.android.example.spinner", SpinnerActivity.class);
    }

    /*
     * Sets up the test environment before each test.
     * @see android.test.ActivityInstrumentationTestCase2#setUp()
     */
    @Override
    protected void setUp() throws Exception {

        /*
         * Call the super constructor (required by JUnit)
         */

        super.setUp();

        /*
         * prepare to send key events to the app under test by turning off touch mode.
         * Must be done before the first call to getActivity()
         */

        setActivityInitialTouchMode(false);

        /*
         * Start the app under test by starting its main activity. The test runner already knows
         * which activity this is from the call to the super constructor, as mentioned
         * previously. The tests can now use instrumentation to directly access the main
         * activity through mActivity.
         */
        mActivity = getActivity();

        /*
         * Get references to objects in the application under test. These are
         * tested to ensure that the app under test has initialized correctly.
         */

        mSpinner = (Spinner)mActivity.findViewById(com.android.example.spinner.R.id.Spinner01);

        mPlanetData = mSpinner.getAdapter();

    }

    /*
     * Tests the initial values of key objects in the app under test, to ensure the initial
     * conditions make sense. If one of these is not initialized correctly, then subsequent
     * tests are suspect and should be ignored.
     */

    public void testPreconditions() {

        /*
         *  An example of an initialization test. Assert that the item select listener in
         *  the main Activity is not null (has been set to a valid callback)
         */
        assertTrue(mSpinner.getOnItemSelectedListener() != null);

        /*
         * Test that the spinner's backing mLocalAdapter was initialized correctly.
         */

        assertTrue(mPlanetData != null);

        /*
         *  Also ensure that the backing mLocalAdapter has the correct number of entries.
         */

        assertEquals(mPlanetData.getCount(), ADAPTER_COUNT);
    }

    /*
     * Tests the UI of the main activity. Sends key events (keystrokes) to the UI, then checks
     * if the resulting spinner state is consistent with the attempted selection.
     */
    public void testSpinnerUI() {

        /*
         * Request focus for the spinner widget in the application under test,
         * and set its initial position. This code interacts with the app's View
         *  so it has to run on the app's thread not the test's thread.
         *
         * To do this, pass the necessary code to the application with
         * runOnUiThread(). The parameter is an anonymous Runnable object that
         * contains the Java statements put in it by its run() method.
         */
        mActivity.runOnUiThread(
            new Runnable() {
                public void run() {
                    mSpinner.requestFocus();
                    mSpinner.setSelection(INITIAL_POSITION);
                }
            }
        );

        // Activate the spinner by clicking the center keypad key

        this.sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);

        // send 5 down arrow keys to the spinner

        for (int i = 1; i <= TEST_POSITION; i++) {

            this.sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
        }

        // select the item at the current spinner position

        this.sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);

        // get the position of the selected item

        mPos = mSpinner.getSelectedItemPosition();

        /*
         * from the spinner's data mLocalAdapter, get the object at the selected position
         * (this is a String value)
         */

        mSelection = (String)mSpinner.getItemAtPosition(mPos);

        /*
         * Get the TextView widget that displays the result of selecting an item from the spinner
         */

        TextView resultView =
                (TextView) mActivity.findViewById(com.android.example.spinner.R.id.SpinnerResult);

        // Get the String value in the EditText object

        String resultText = (String) resultView.getText();

        /*
         * Confirm that the EditText contains the same value as the data in the mLocalAdapter
         */

        assertEquals(resultText,mSelection);
    }

    /*
     *  Tests that the activity under test maintains the spinner state when the activity halts
     *  and then restarts (for example, if the device reboots). Sets the spinner to a
     *  certain state, calls finish() on the activity, restarts the activity, and then
     *  checks that the spinner has the same state.
     *
     */

    public void testStateDestroy() {

        /*
         * Set the position and value of the spinner in the Activity. The test runner's
         * instrumentation enables this by running the test app and the main app in the same
         * process.
         */


        mActivity.setSpinnerPosition(TEST_STATE_DESTROY_POSITION);

        mActivity.setSpinnerSelection(TEST_STATE_DESTROY_SELECTION);

        // Halt the Activity by calling Activity.finish() on it

        mActivity.finish();

        // Restart the activity by calling ActivityInstrumentationTestCase2.getActivity()

        mActivity = this.getActivity();

        /*
         * Get the current position and selection from the activity.
         */

        int currentPosition = mActivity.getSpinnerPosition();
        String currentSelection = mActivity.getSpinnerSelection();

        // test that they are the same.

        assertEquals(TEST_STATE_DESTROY_POSITION, currentPosition);

        assertEquals(TEST_STATE_DESTROY_SELECTION, currentSelection);
    }

    /*
     * Tests that the activity under test maintains the spinner's state when the activity is
     * paused and then resumed.
     *
     * Calls the activity's onResume() method. Changes the spinner's state by
     * altering the activity's View. This means the test must run
     * on the UI Thread. All the statements in the test method may be run on
     * that thread, so instead of using the runOnUiThread() method, the
     * @UiThreadTest is used.
     */
    @UiThreadTest

    public void testStatePause() {

        /*
         * Get the instrumentation object for this application. This object
         * does all the instrumentation work for the test runner
         */

        Instrumentation instr = this.getInstrumentation();

        /*
         * Set the activity's fields for the position and value of the spinner
         */

        mActivity.setSpinnerPosition(TEST_STATE_PAUSE_POSITION);

        mActivity.setSpinnerSelection(TEST_STATE_PAUSE_SELECTION);

        /*
         *  Use the instrumentation to onPause() on the currently running Activity.
         *  This analogous to calling finish() in the testStateDestroy() method.
         *  This way demonstrates using the test class' instrumentation.
         */

        instr.callActivityOnPause(mActivity);

        /*
         * Set the spinner to a test position
         */

        mActivity.setSpinnerPosition(0);

        mActivity.setSpinnerSelection("");

        /*
         * Call the activity's onResume() method. This forces the activity
         * to restore its state.
         */

        instr.callActivityOnResume(mActivity);

        /*
         * Get the current state of the spinner
         */

        int currentPosition = mActivity.getSpinnerPosition();

        String currentSelection = mActivity.getSpinnerSelection();

        assertEquals(TEST_STATE_PAUSE_POSITION,currentPosition);
        assertEquals(TEST_STATE_PAUSE_SELECTION,currentSelection);
  }

}
跑的时候,界面会随之变动,不过起
instrumentation确实比较慢
















AndroidJunitRunnerSample:2015年10月17日的UnitTest项目 AndroidJUnitRunner示例 新的android测试运行程序为Android测试带来了Junit4支持。 该样本快速概述了一些新功能,例如测试注释,参数化测试和测试套件创建。 CalculatorTest.java包含用于计算器逻辑的JUnit4样式单元测试。 CalculatorAddParameterizedTest.java包含JUnit4样式测试,并使用@Parameters批注对具有不同值的单个测试进行参数化。 CalculatorInstrumentationTest.java使用JUnit4样式测试来测试CalculatorActivity的Ui OperationHintInstrumentationTest.java使用JUnit3样式测试来测试CalculatorActivity的Ui 该项目使用Gradle构建系统。 您不需要IDE即可构建和执行 立即下载

相关推荐

《跨界杂谈》华为印象(五):高度集权的矩阵式架构

高度集权的矩阵式架构 “高度集权的矩阵式架构”不是官方术语。是笔者的一位同事非常经典的总结。解释这个句话还是有点困难的,笔者入职华为三年也没彻底搞明白,在这里只能尝试性的解释一下。 矩阵 我们先看一下“矩阵”。华为有两套部门职能体系,华为内部术语,叫实线部门和虚线部门。由实线与虚线部门交叉构成矩阵。大部分(但不是所有)华为员工都由两个部门(两个领导)进行管理。对员工而言,所谓的实线部

《云计算架构技术与实践》 3008

Android 单元测试(四) 之AndroidJUnitRunner基础

AndroidJUnitRunner,Google官方的android单元测试框架之一,适用于 Android 且与 JUnit 4 兼容的测试运行器!测试运行器可以将测试软件包和要测试的应用加载到设备、运行测试并报告测试结果。 此测试运行器的主要功能包括: JUnit 支持 访问仪器信息 测试筛选 测试分片 要求 Android 2.2(API 级别 8)或更高版本。 JUnit 支...

孙朝阳的博客 1万+

Java开发者必备:Ollama4j客户端库全面指南与实战

在AI应用开发领域,本地部署大型语言模型(LLM)已成为降低成本和提升隐私安全的重要趋势。其核心原理是通过REST API与模型服务器交互,实现文本生成、对话和语义理解等功能。这一技术为Java生态系统带来了显著的工程价值,使开发者能够便捷地将AI能力集成到企业级应用中。Ollama4j作为一款专为Java设计的轻量级客户端库,通过封装底层HTTP通信和JSON处理,提供了类型安全、面向对象的API,极大地简化了与Ollama服务器的交互。它全面支持流式生成、多轮对话、嵌入向量计算以及高级的**工具调用**

weixin_28295799的博客 439

1.Android JUnit Runner(使用AndroidStudio)

一、Android JUnit Runner介绍 1.Android JUnit Runner 1)是一个测试运行器,用于运行Junit3和Junit4的Android测试包 2)替换Instrumentation Test Runner(一个比较旧的测试运行器) 3)支持Instrumentation Test Runner所有特性,但又进行了扩展 4)保持了所有Instru...

weixin_30375247的博客 263

Hierarchical-Localization 环境配置与依赖管理全攻略

本文提供了Hierarchical-Localization(hloc)视觉定位工具箱从零开始的环境配置与依赖管理全攻略。针对Windows、Ubuntu和macOS三大操作系统,详细解析了Python版本选择、PyTorch与CUDA版本匹配、pycolmap版本锁定等核心依赖的安装步骤,并汇总了权重文件格式、NumPy版本、路径配置等常见问题的排查与解决方案,旨在帮助用户高效搭建稳定的hloc开发环境。

weixin_29066781的博客 335

FANUC机器人KAREL编程实战:手把手教你用SOCKET指令连接外部设备(附完整.KL文件)

本文详细解析了FANUC机器人KAREL编程中SOCKET指令的应用,从开发环境配置到工业级通讯全流程,涵盖网络参数设置、模块化代码设计、错误处理及现场调试技巧。通过实战案例,帮助开发者掌握与外部设备稳定连接的关键技术,提升工业自动化系统的通讯可靠性。

weixin_30907935的博客 229

Android自动化测试基础知识——JUnit4、 AndroidJunitRunner(支持安卓的Junit)、 Espresso

目录 配置 JUnit4 JUnit4基础方法注解 JUnit4常用断言 Hamcrest与assertThat 测试方法执行顺序 Espresso 依赖的类库 使用 Rules 创建的 JUnit4 测试实例: 使用 onView 查找视图 在视图上执行操作 检查一个视图是否满足断言 在AdapterView控制器(ListView,GridView, ...)中...

jackron2014的博客 1476

四旋翼无人机控制算法实战:从PID到MPC的路径跟踪

本文深入探讨了四旋翼无人机控制算法的演进路径,从基础的PID控制到高级的MPC算法,详细解析了各类算法的原理、实现技巧及适用场景。通过实战案例对比分析,为开发者提供从算法选型到参数调优的全方位指导,助力提升无人机飞行控制的精度与稳定性。

weixin_29090917的博客 245

spoon+robotium+jenkins进行自动化持续回归测试

自动化测试的意义:         别说是外行人,即使是正在从事自动化测试工作的人来说,现在或曾经都或多或少有过这样的疑惑,辛苦写了自动化测试用例,却基本发现不了问题,其意义何在?在说明这个意义前先看下质量的定义。 质量的定义:         维基百科中对于品质(Quality)的定义:中国大陆亦称为“质量”,可指物品的特征、品性、本质,也可指商品或服务的水准、质量。 影响品

hunterno4的专栏 1万+

Veeam Backup Replication Console 13 备份 PVE

本文介绍了如何通过Veeam Backup & Replication控制台配置与Proxmox VE(PVE)服务器的连接,包括主机地址、用户名密码和SSH信任设置。随后详细说明了部署备份Worker虚拟机的步骤,涵盖网络配置和VM创建。接着指导用户创建PVE虚拟机备份任务,包括命名、选择备份对象、存储位置、备份类型设置,以及配置备份计划任务。最后描述了备份测试执行过程,从启动备份到完成状态通知的完整流程。整个操作涉及服务器连接、Worker部署、备份配置和任务执行四个主要环节。

极致,细节 1627

基于Simulink的固态变压器(SST)多级协同控制​

本文介绍了基于Simulink的固态变压器(SST)多级协同控制方法。SST作为智能电网关键设备,其三级架构(AC-DC整流、DC-DC隔离、DC-AC逆变)存在级间耦合问题。文章提出纵向解耦与横向联动相结合的协同控制策略,详细推导了各级控制算法,并通过Simulink实现了10kV/400V级联型SST系统建模。仿真结果显示,在±20%电网波动和0-100%负载跳变下,系统能保持直流母线电压波动<2%。文章还提供了工程部署建议和代码生成方法,为SST的研发提供了实用指导。

amy_mhd的博客 305

Android Studio使用AndroidJUnitRunner进行单元测试

目前google是推荐使用AndroidJUnitRunner来进行单元测试的。 如果想使用InstrumentationTestRunner推荐下面的一篇文章: http://blog.csdn.net/zhaokaiqiang1992/article/details/45332513 使用AndroidJUnitRunner进行测试的时候,需要做在build.gradle里面添加

zhuhai__yizhi的专栏 1万+

告别标注地狱!YOLO+CLIP多模态零样本检测全实战:图文联合推理,想检测什么直接输文字,不用训模型

这套方案我给朋友的超市用了快3个月,运行极其稳定,临期商品的检测准确率能到96%,后续加了“货架空货检测”“通道杂物堆积检测”,都是改一行文本就搞定,完全不用重新开发,朋友说省了十几万的定制开发费用。很多做计算机视觉的朋友,总觉得目标检测必须标数据、训模型,其实不是的。现在多模态大模型的能力已经足够强,把YOLO的定位能力和CLIP的图文泛化能力结合起来,就能用极低的成本,搞定绝大多数定制化检测需求。对于我们开发者来说,技术的价值从来不是炫技,而是用最简单的方案,解决最实际的问题。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 523

对JUnit 4和安卓测试代码的简单分析

JUnit 4是一种流行的Java单元测试工具。使用JUnit 4和androidx.test包可以为Android程序编写单元测试和插桩测试。下面我对JUnit 4在Android程序上的使用做一些简单的分析。

tq1086的博客 425

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

Android中的JUnit和Java中的JUit

Android中的JUnit和Java中的Junit<一>JUnit简介 JUnit测试就是单元测试,对于业务逻辑代码进行测试,也就是对于业务逻辑层进行 测试测试目标:方法 1.测试方法的执行是否成功。 2.测试方法的返回值是否成功。(断言测试) <二>Android中的JUnit测试在Android开发中,JUnit测试有两种情况: 1. 在本项目中直

chenlxhf的博客 1076

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

Android 单元测试之JUnit和Mockito

Android 单元测试之JUnit和MockitoJUnit使用JUnit测试框架需要引入依赖,在新建项目的时候,Android Studio已自动帮我们引入了该依赖dependencies { ... testCompile 'junit:junit:4.12' } 注解说明JUnit提供了一些注解帮助我们更好的完成测试 @Before 该方法在每次测试方法调用前都会调用

朱豪凯的博客 5036

Android 系列 3.4使用Android Studio和JUnit进行测试

3.4使用Android Studio和JUnit进行测试 伊恩达尔文 问题 您想要使用JUnit来测试基于Android Studio的应用程序。 解 对于独立单元测试,请使用“test”文件夹;对于完整的Android单元测试,使用“androidTest”文件夹。 讨论 为了本练习的目的,我们将创建一个新的Android Studio项目(参见Recipe 1.9)。将项目命名

曹浩洋的专栏 1850

Android 系列 3.5使用Robolectric和JUnit测试4

3.5使用Robolectric和JUnit测试4 问题 你喜欢单元测试,但Android的原始测试框架是基于古老的Android 3.8,它运行在模拟器,所以它的速度很慢。 解 使用Robolectric,JUnit 4测试跑者是快。 讨论 这些说明是为Eclipse设置的。 假设您的“主”项目设置为正常的Android项目,在此项目中创建一个名为例如“test”的文件夹(

曹浩洋的专栏 1033

【android】AS中使用Junit单元测试和Android JUnit 单元测试

AS中使用Junit单元测试和Android JUnit 单元测试 在AndroidStudio中使用单元测试 1. 前言 在Android开发中,如果对一个简单的功能,每次修改代码都重新运行到设备中进行测试,会浪费大量时间,降低开发工作效率。如果使用单元测试,编写单元测试类,执行测试单元测试类就可以对某些功能进行测试,大大提升了开发工作效率。 2. 添加单元测试支持 在AndroidStudio项目中,如果是新版本的AndroidStudio中新建的,会自动添加了单元测试的支持,如果旧项目,没有添加单元测

qq_36234964的博客 3546

Android 系列 3.6使用ATSL,Espresso和JUnit测试4

3.6使用ATSL,Espresso和JUnit测试4 问题 你想使用最新的官方测试软件 解 使用Android测试支持库的Espresso部分。 Espresso使用JUnit 4像RoboLectric,但仍然要求测试打包并在仿真器或设备上运行。 讨论 Espresso是一个相对较新的测试框架,旨在将JUnit 4和Hamcrest匹配样式的优势带给Android测试。与上

曹浩洋的专栏 1166

【单元测试】【Android】JUnit 4 和 JUnit 5 的差异记录

新手小白的记录,通过IDE生成单元测试类的方法。

。 1008

【Android】JUnit和Espresso单元测试新手快速入门

Android单元测试,特别是Espresso框架,依赖于Gradle插件和SDK版本。Gradle插件版本不兼容,SDK版本不兼容,手机不支持时,单元测试都可能会执行失败。测试任务执行完毕,会在app/build/reports目录下生成测试报告。点击被Test标注的方法,左侧的运行按钮,就可以执行测试任务。点击被Test标注的方法,左侧的运行按钮,就可以执行测试任务。可能会遇到的意外比较多,如果不幸遇坑,需要靠自己去耐心尝试。报告会统计所有测试任务的执行结果,已经通过率。

天天向上 Up Up Up (*^▽^*) 1032

Android之文件操作和JUnit

1>写一个文件保存和读取的应用程序。和javaEE一样MVC的设计模式,在android里M应该是Service层,那么Service层和view层应该可以并行开发。因为程序比较简单,我就先写view了。 <LinearLayout xmlns:android="http:

duantl的专栏 977

AndroidX Junit4 测试 依赖和Android Room 的依赖

AndroidX Test 依赖 dependencies { // Core library androidTestImplementation 'androidx.test:core:1.0.0' // AndroidJUnitRunner and JUnit Rules androidTestImplementation 'androidx.test:runner:1.1....

miskss的博客 6206
上一篇: AsyncTask activity异步线程
下一篇: Linux安装jdk
partner4java
博客等级 码龄17年 481粉丝 183原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址