android自動化測試--Robolectric

Robolectric 是一套開源的Android單元測試框架,其經過一系列對底層Android元素的替換來實現對原有元素調用的模擬,從而實現脫離模擬器的測試。java

Robolectric 的測試工程是一個java工程,下面來介紹如何在eclipse下使用Robolectric 實現自動化測試:框架

一、在被測工程中新建test 文件夾eclipse

二、新建測試工程(java project)單元測試

File->New->Java Project測試

三、remove srcui

四、把被測項目中的test文件夾添加到資源中ip

五、配置build pathci

測試工程右鍵->Build Path->Configure Build Path資源

1)Projects,添加被測工程rem

2)Libraries

  爲java項目添加上須要的junit4庫,

  Robolectric.jar 下載地址: http://pan.baidu.com/s/1nDA8S

 

六、配置run configurations

測試工程右鍵->Run As ->Run As Configurations->雙擊junit

1)Test

2)Arguments

 

點擊「Multiple launchers available Select one…」->選中「Use configuration specific settings」->選擇「Eclipse JUnit Launcher」 肯定

 

到此一個測試工程就配置完了,下面要對其進行驗證

 

未完待續

相關文章
相關標籤/搜索