标签:build 测试 编写 oncreate 入口 java ace 电脑 sem
testImplementation ‘junit:junit:4.12‘ androidTestImplementation ‘com.android.support.test:runner:1.0.2‘ androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.2‘
package com.xiaoying.untitestdemo; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.os.Bundle; import android.support.test.InstrumentationRegistry; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; /** * Created by yinglovezhuzhu@gmail.com on 2018/5/13. */ public class MainActivityTest { private Context mTargetContext; @Before public void setUp() throws Exception { mTargetContext = InstrumentationRegistry.getTargetContext(); } @Test public void onCreate() { try { ApplicationInfo applicationInfo = mTargetContext.getPackageManager().getApplicationInfo(mTargetContext.getPackageName(), PackageManager.GET_META_DATA); Bundle metaData = applicationInfo.metaData; String data = metaData.getString("com.xiaoying.TEST"); assertEquals("1234567890", data); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } } }
package com.xiaoying.untitestdemo; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.*; /** * Created by yinglovezhuzhu@gmail.com on 2018/5/13. */ public class UtilsTest { @Before public void setUp() throws Exception { } @Test public void isEmpty() { assertEquals(true, Utils.isEmpty("")); } }
标签:build 测试 编写 oncreate 入口 java ace 电脑 sem
原文地址:https://www.cnblogs.com/chenxibobo/p/9657130.html