- Learning Android Application Testing
- Paul Blundell Diego Torres Milano
- 273字
- 2021-07-23 19:58:55
The TestCase base class
This is the base class of all other test cases in the JUnit framework. It implements the basic methods that we were analyzing in the previous examples (setUp()
). The TestCase
class also implements the junit.framework.Test
interface, meaning it can be run as a JUnit test.
Your Android test cases should always extend TestCase
or one of its descendants.
The default constructor
All test cases require a default constructor because, sometimes, depending on the test runner used, this is the only constructor that is invoked, and is also used for serialization.
According to the documentation, this method is not intended to be used by "mere mortals" without calling setName(String name)
.
Therefore, to appease the Gods, a common pattern is to use a default test case name in this constructor and invoke the given name
constructor afterwards:
public class MyTestCase extends TestCase { public MyTestCase() { this("MyTestCase Default Name"); } public MyTestCase(String name) { super(name); } }
Tip
Downloading the example code
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
- Kibana Essentials
- Progressive Web Apps with React
- 零基礎學C++程序設計
- Web交互界面設計與制作(微課版)
- 區塊鏈技術進階與實戰(第2版)
- Mastering C++ Multithreading
- .NET 4.5 Parallel Extensions Cookbook
- Spring 5 Design Patterns
- Bootstrap for Rails
- Mastering jQuery Mobile
- 大學計算機基礎實訓教程
- Java高并發編程詳解:深入理解并發核心庫
- 虛擬現實建模與編程(SketchUp+OSG開發技術)
- Raspberry Pi Blueprints
- Cocos2D Game Development Essentials