TUTORIAL: Advanced recording
Recording flow
c) Command view tree d) Screenshot, Add method, Delete
- Right click on your project in the Package Explorer
- Run As – > Run Configurations…
Test command view
The command view tree (Pic.1.c), located in the center of the screen, features three kind of items:
A test case – single node, which represents the actual test file.
Test methods – the individual methods in the test file.
Test commands – the recorded actions – touches, drags, changes of activity etc.
We recommend that you split your test case to many smaller methods, rather than recording everything to single huge test method.
Adding methods
Add method to the test case:
Recording Robotium test returns a plain JUnit test case which test methods are executed according to JUnit own test method life cycle. There is no guaranty to the order the test methods will be run. Additionally, there are two special methods setUp() and tearDown(). They are called, respectively, before and after execution of each test method. Those methods are used to prepare so called fixture – setUp() initiates it, tearDown() cleans things up. The fixture is a scaffolding common for each test method of the test case. In our case, setUp() method creates a new instance of a Robotium Solo class. When the object is created its loads the main activity of the application – the starting point for each test method.
Adding commands
You can add commands manually if recorder didn’t recognize any events or if you wanna do something beyond normal recording process. To do this:
- Right click the command, method, test case to open context menu
- Choose New command
- Choose the one you want to add
- Set needed properties in popped-up dialog and press OK
- on test case – new command will be added as last command in current recording method
- on method – new command will be added as last command in this method
- on command – new command will be added after selected one
Manual addition commands is not only useful for elements which wasn’t recognized properly but is also very useful together with assertion feature. You can add one of five asserts and take more control on test.
Editing commands
You can edit previously added or recorded commands. Do to it:
- Double-click on chosen command
- Set needed properties in popped-up dialog and press OK
- Right click the command to open context menu
- Choose edit command
- Set needed properties in popped-up dialog and press OK
Set currently recorded method
- Right click the method in the command view to open context menu.
- Choose Set current recording
Renaming methods
You can always rename the method you have created. To rename:
- Right click the method in the command view to open context menu.
- Choose Rename method
- Give the new name for the method and press OK
Deleting methods
If you wish to remove one or more methods do the following:
- Select methods to deletion in the command view. Hold Ctrl button on keyboard to select multiple methods.
- Make sure that no test commands are selected.
- Press button (Pic.1.d) or select Remove method in context menu.
- Confirm by pressing Yes button.
Note: You cannot remove method that is currently being recorded – switch the recording to other method first.
Deleting commands
Similarly to removing methods you can remove test commands:
- Select commands to deletion in the command view. Hold Ctrl button on keyboard to select multiple methods.
- Make sure that no methods are selected.
- Press button (Pic.1.d) or select Remove command in context menu.
Note: It is quite common to remove test commands. To simplify operation there is no confirmation window – just be careful!
Copy, cut and paste commands/methods
You can copy/cut methods and commands:
- Select methods/commands to copy/cut in the command view. Hold Ctrl button on keyboard to select multiple methods/commands.
- Press Ctrl+c or Copy method/command in context menu(or Ctrl+x or Cut method/command in context menu for cut).
- Click place where you want to paste methods/commands.
- Press Paste before/after in context menu.
Drag&drops commands
You can drag and drop commands inside method or even between methods.
Hot keys
You can use hot keys to quickly push buttons when recording:
- Ctrl+b – Paster before.
- Ctrl+c – Copy method/command.
- Ctrl+x – Cut method/command.
- Ctrl+n – Add new method.
- Ctrl+r – Set current recording.
- Ctrl+v – Paster after.
- Ctrl+e – edit command.
- Delete – Delete method/command.
- F2 – Rename method.
Screenshots
Note: Robotium stores screenshot on the SD card in the device, whereas monkerunner stores screenshots on the specified directory on the machine which executes the test scripts.
<uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” />
Note: If you are using emulator to play Robotium tests with screenshots, make sure it has SD card configured.
Before we start, please download the latest version of Testdroid Recorder and install it in Eclipse. Here you will find [...]
May 15th, 2012 by Bitbar Woot! The Testdroid team just received an invitation from Google Android Developer Advocates team to play [...]
- Android's mktshare jumped 20%-points to 56%, iPhones just 6%-points from Q1/11 to Q1/12 http://t.co/v7MXpsXf
18.05.2012 - RT @FredLardieg: Great post from @chrisvelazco about Android fragmentation: http://t.co/4iqGtOjI. Check out Testdroid http://t.co/iWUJM6ei to fix the problem
17.05.2012 - Come and see a live demo on testing your app automatically on 100+ real devices on booth 405 #AnDevCon #Testdroid
16.05.2012

