Auto-tools/Projects/Robocop/WritingTests: Difference between revisions

Line 3: Line 3:
Robotium is a test framework created to make it easy to write powerful and robust automatic black-box test cases for Android applications. Robocop provides a wrapper around Robotium making it even easier to write and execute UI tests for native Fennec.
Robotium is a test framework created to make it easy to write powerful and robust automatic black-box test cases for Android applications. Robocop provides a wrapper around Robotium making it even easier to write and execute UI tests for native Fennec.


= Setup =
= Creating a new test =


Copying a test from the examples is the best way to start.  
The best way to create a new test is to copy and modify an existing test case -- see mobile/android/base/tests.  


Your test should be in the file test[Feature].java.in -- see mobile/android/base/tests.
Create a new file in the test directory named test[YourFeature].java.in.


The flow of the test will go from starting the application to killing it.
The top of each test file must have:
 
The top of each test case file must have:
<pre>
<pre>
#filter substitution
#filter substitution
Line 23: Line 21:


Each test class must have three methods:  
Each test class must have three methods:  
 
<pre>
setUp() - Starts Fennec and sets up commonly used member variables. This is usually very similar for every test class.
protected void setUp() // Starts Fennec and sets up commonly used member variables. This is usually very similar for every test class.
test[Feature]() - Your test code goes here.
public void test[YourFeature]() // Your test code goes here. Use the Robocop API to access Fennec elements, click, send keys, and assert conditions.
tearDown() - Clean up. This is usually very similar for every test class.
public void tearDown() // Clean up. This is usually very similar for every test class.
</pre>


= APIs  =
= APIs  =
Confirmed users
1,759

edits