【配置】
defaultConfig {
... ...
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
testImplementation 'junit:junit:4.13.1'
testImplementation 'org.mockito:mockito-core:2.19.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test:rules:1.3.0'
【使用】
import android.util.Log;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class DemoTest {
@Test
public void testLog(){
Log.d("test", "测试一下,单元测试");
}
}
【学习】
暂略