美文网首页Android
Create android unit test for and

Create android unit test for and

作者: JaedenKil | 来源:发表于2017-11-24 17:11 被阅读4次
  • Locate the class you wish to test, press Shift + Ctrl + T.
  • In the newly shown menu, choose Create New Test.
  • In Test library , choose JUnit 4.
  • Name the Class name.
  • Press OK.
  • Choose destination directory, such as app\src\androidTest\....
  • Press OK.
  • Remove possible unnecessary newly generated directories.
  • In app level build.gradle , such as app\build.gradle, add necessary dependencies. Such as:
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:support-annotations:23.1.1'
    testCompile 'junit:junit:4.12'
    androidTestCompile 'com.android.support:support-annotations:23.1.1'
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.android.support.test:rules:0.5'
    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
  • Solve possible dependency conflicts.
  • In the newly created java test file, Alt + Insert to generate new method automatically.

相关文章

网友评论

    本文标题:Create android unit test for and

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