可以看到上面的从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