Robotium第二天:setUp ()與tearDown ()的使用
阿新 • • 發佈:2019-02-10
可以看到上面的從TestCase父類中繼承過來的保護型別的方法,寫出了上面的方法的功能。
在android Developer中有如下的解釋
protected void setUp ()
Since: API Level 3
Sets up the fixture, for example, open a network connection. This method is called before a test is executed.
protected void tearDown ()
Since: API Level 3
Make sure all resources are cleaned up and garbage collected before moving on to the next test. Subclasses that override this method should make sure they call super.tearDown() at the end of the overriding method.
setUp ()用來初始設定,如啟動一個Activity,初始化資源等。
tearDown ()則用來垃圾清理與資源回收。
附上部落格連線:http://book.51cto.com/art/201111/301862.htm
http://www.oschina.net/question/54100_27061