美文网首页
Android AndroidJUnit4 单元测试

Android AndroidJUnit4 单元测试

作者: 不会看源码 | 来源:发表于2020-11-04 11:18 被阅读0次

    【配置】

        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", "测试一下,单元测试");
        }
    }
    
    androidTest.png

    【学习】

    暂略
    

    相关文章

      网友评论

          本文标题:Android AndroidJUnit4 单元测试

          本文链接:https://www.haomeiwen.com/subject/fctgvktx.html