close

1.gradle 新增依賴

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.0.2'
androidTestImplementation 'androidx.test:rules:1.2.0'

2.取得context

import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4ClassRunner.class)
public class Test {
  Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
}

 

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 JBLin 的頭像
    JBLin

    a0973378273的部落格

    JBLin 發表在 痞客邦 留言(0) 人氣()