Android JUnit test for SQLiteOpenHelper

前端 未结 4 1246
挽巷
挽巷 2020-12-08 00:52

I am new to junit testing.

Can anyone help me , how to test my SQLiteOpenHelper class.

Means what classes I have to implement and how to test my

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-08 01:25

    You can write android database test in JUnit4 style as well. You just need to add following dependency in your database

    androidTestCompile('com.android.support.test:runner:0.3'){
            exclude group: 'com.android.support', module: 'support-annotations'
        }
    

    And mark you Test class as follows

    @RunWith(AndroidJUnit4.class)
    public class DatabaseTest {
       @Test
       public void myFirstTest(){
          //your test
       }
    }
    

提交回复
热议问题